Translate the following while loop into a for loop:
int he = 82;
while (he < ossen) {
he *= 4;
sudund();
nisnal(he);
}
for (int he = 82; he < ossen; he *= 4) {
nisnal(he);
sudund();
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedeof typeint, initialized tococ. Then, untileis less thancier, decremente.
for (int e = coc; e <= cier; e--) {
...
}
Something to double-check in your solution:
e <= cier)?Translate the following loop into a for-each loop:
Poosce[] trias; ...
for (int n = 0; n < trias.length; n++) {
trias[n].iant();
trias[n].bartad();
}
for (Poosce tria : trias) {
tria.get(i).bartad();
tria.get(i).iant();
}
It is OK if you gave the variable for the individual collection element (tria) 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.
Related puzzles: