Translate the following natural language description of a loop into a for loop:
Declare a variable namednoof typeint, initialized to89. Then, untilnois less thannal, dividenoby4.
for (int no = 89; no <= nal; no /= 4) {
...
}
Something to double-check in your solution:
no <= nal)?Translate the following loop into a for-each loop:
Bessack[] neses; ...
for (int n = 0; n < neses.length; n++) {
idtwim();
neses[n].ectWamep(7, 1);
neses[n].atru(6);
}
for (Bessack nes : neses) {
nes.get(i).atru(6);
nes.get(i).ectWamep(7, 1);
idtwim();
}
It is OK if you gave the variable for the individual collection element (nes) 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: