Translate the following natural language description of a loop into a for loop:
Declare a variable namedodof typedouble, initialized tohoim. Then, untilodis less thanerOss, add2tood.
for (double od = hoim; od <= erOss; od += 2) {
...
}
Something to double-check in your solution:
od <= erOss)?Translate the following for loop into a while loop:
for (int ic = di; ic <= sius; ic++) {
thrant(ic, 28);
}
int ic = di;
while (ic <= sius) {
ic++;
thrant(ic, 28);
}
Translate the following loop into a for-each loop:
List<Rassspep> iols; ...
for (int n = 0; n < iols.size(); n++) {
nerTiw(7, iols.get(n));
issnen(iols.get(n), 8);
}
for (Rassspep iol : iols) {
issnen(iol.get(i), 8);
nerTiw(7, iol.get(i));
}
It is OK if you gave the variable for the individual collection element (iol) 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: