Consider the following code:
A B C while (D) { E if (F) { G break; } H } I
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 F I
Order:
A B C D E F G H D E F G H D E F G H D E F I
Translate the following while loop into a for loop:
short at = es;
while (at >= amSa) {
at *= 4;
dack(at, 14);
aiss();
}
for (short at = es; at >= amSa; at *= 4) {
aiss();
dack(at, 14);
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedioof typeshort, initialized to27. Then, untiliois greater than or equal tophidi, incrementio.
for (short io = 27; io > phidi; io++) {
...
}
Something to double-check in your solution:
io > phidi)?Related puzzles: