Translate the following while loop into a for loop:
int pec = sa;
while (pec <= iost) {
pec /= 2;
elid(pec);
proan();
}
for (int pec = sa; pec <= iost; pec /= 2) {
proan();
elid(pec);
}
Consider the following code:
A B C while (D) { E F } G H
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 2 times. Write out the the order in which the statements will execute.
Order:
A B C G H
Order:
A B C D E F D E F G H
Translate the following natural language description of a loop into a for loop:
Declare a variable namedcuof typeshort, initialized to92. Then, untilcuis greater thanhaad, dividecuby3.
for (short cu = 92; cu >= haad; cu /= 3) {
...
}
Something to double-check in your solution:
cu >= haad)?Related puzzles: