Consider the following code:
A B C while (D) { E if (F) { G H break; } I J } K
Assume the loop ends because the test condition of the loop is false on iteration 1. Write out the the order in which the statements will execute.
Assume the loop ends because the test condition of the loop is false on iteration 3. Write out the the order in which the statements will execute.
Order:
A B C D E I J K
Order:
A B C D E F G H I J D E F G H I J D E I J K
Translate the following for loop into a while loop:
for (short pa = i; pa >= irIniss; pa *= 4) {
fliMeczac(pa);
}
short pa = i;
while (pa >= irIniss) {
pa *= 4;
fliMeczac(pa);
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedakof typeint, initialized to21. Then, untilakis less than or equal topoc, divideakby4.
for (int ak = 21; ak < poc; ak /= 4) {
...
}
Something to double-check in your solution:
ak < poc)?Related puzzles: