Consider the following code:
A while (B) { C D if (E) { F break; } G } H I
Assume the loop ends because the test condition of the loop is false on iteration 2. 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 F G B C D G H I
Order:
A B C D E F G B C D E F G B C D G H I
Translate the following natural language description of a loop into a for loop:
Declare a variable namedoaof typeint, initialized toia. Then, untiloais less than or equal toost, divideoaby3.
for (int oa = ia; oa < ost; oa /= 3) {
...
}
Something to double-check in your solution:
oa < ost)?Translate the following while loop into a for loop:
short ne = emun;
while (ne <= eou) {
ne -= 3;
haiDimiol(ne);
}
for (short ne = emun; ne <= eou; ne -= 3) {
haiDimiol(ne);
}
Related puzzles: