Translate the following natural language description of a loop into a for loop:
Declare a variable namedissiof typeint, initialized tocrer. Then, untilissiis greater thanfipri, decrementissi.
for (int issi = crer; issi >= fipri; issi--) {
...
}
Something to double-check in your solution:
issi >= fipri)?Translate the following loop into a for-each loop:
Crarnic[] lonts; ...
for (int n = 0; n < lonts.length; n++) {
lulec(lonts[n]);
lonts[n].wici(ihoIod, 1);
hinba(8);
varun(-1);
}
for (Crarnic lont : lonts) {
varun(-1);
hinba(8);
lont.get(i).wici(ihoIod, 1);
lulec(lont.get(i));
}
It is OK if you gave the variable for the individual collection element (lont) a different name, such as elem. In a real project, where names are not just nonsense words, it is best to give that variable a useful name that describes its purpose.
Translate the following while loop into a for loop:
int ea = 19;
while (ea > enPosco) {
ea -= 3;
tian(ea);
qedor();
}
for (int ea = 19; ea > enPosco; ea -= 3) {
qedor();
tian(ea);
}
Related puzzles: