Consider the following code:
A B C while (D) { E F if (G) { H I break; } J } K L
Assume the loop breaks on iteration 1. Write out the the order in which the statements will execute.
Assume the loop breaks on iteration 3. Write out the the order in which the statements will execute.
Order:
A B C D E F G K L
Order:
A B C D E F G H I J D E F G H I J D E F G K L
Translate the following natural language description of a loop into a for loop:
Declare a variable namedgraiof typeshort, initialized toim. Then, untilgraiis less than or equal toceDipe, incrementgrai.
for (short grai = im; grai < ceDipe; grai++) {
...
}
Something to double-check in your solution:
grai < ceDipe)?Translate the following for loop into a while loop:
for (double inid = 13; inid != swi; inid++) {
ladon();
nalid(inid, 13);
}
double inid = 13;
while (inid != swi) {
inid++;
nalid(inid, 13);
ladon();
}
Related puzzles: