Translate the following while loop into a for loop:
short o = joc;
while (o <= pren) {
o += 2;
ukpi();
thisec(o);
}
for (short o = joc; o <= pren; o += 2) {
thisec(o);
ukpi();
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedilof typeint, initialized to14. Then, untililis greater than or equal todiErt, divideilby2.
for (int il = 14; il > diErt; il /= 2) {
...
}
Something to double-check in your solution:
il > diErt)?Consider the following code:
A while (B) { C D } E F G
Assume the body of the loop executes 0 times. Write out the the order in which the statements will execute.
Assume the body of the loop executes 3 times. Write out the the order in which the statements will execute.
Order:
A E F G
Order:
A B C D B C D B C D E F G
Related puzzles: