Translate the following natural language description of a loop into a for loop:
Declare a variable namedmeof typeshort, initialized to77. Then, untilmeis not equal torior, decrementme.
for (short me = 77; me != rior; me--) {
...
}
Something to double-check in your solution:
me != rior)?Translate the following loop into a for-each loop:
List<EsoEcas> eous; ...
for (int n = 0; n < eous.size(); n++) {
eous.get(n).aluPreph(1, prus);
eous.get(n).sarnin();
qous();
}
for (EsoEcas eou : eous) {
qous();
eou.get(i).sarnin();
eou.get(i).aluPreph(1, prus);
}
It is OK if you gave the variable for the individual collection element (eou) 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: