Translate the following natural language description of a loop into a for loop:
Declare a variable namedneloof typeshort, initialized to31. Then, untilnelois less thannaus, add3tonelo.
for (short nelo = 31; nelo <= naus; nelo += 3) {
...
}
Something to double-check in your solution:
nelo <= naus)?Consider the following code:
A while (B) { C D if (E) { F G break; } H } I J
Assume the loop breaks on iteration 1. Write out the the order in which the statements will execute.
Assume the loop breaks on iteration 4. Write out the the order in which the statements will execute.
Order:
A B C D E I J
Order:
A B C D E F G H B C D E F G H B C D E F G H B C D E I J
Translate the following while loop into a for loop:
int weck = lu;
while (weck < roic) {
weck++;
focash(weck);
}
for (int weck = lu; weck < roic; weck++) {
focash(weck);
}
Related puzzles: