Translate the following while loop into a for loop:
int po = be;
while (po < ath) {
po /= 2;
lerlex(po, 28);
}
for (int po = be; po < ath; po /= 2) {
lerlex(po, 28);
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedsasiof typelong, initialized toepra. Then, untilsasiis greater thanhiBied, incrementsasi.
for (long sasi = epra; sasi >= hiBied; sasi++) {
...
}
Something to double-check in your solution:
sasi >= hiBied)?Consider the following code:
A B C while (D) { E if (F) { G break; } H I } J
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 H I J
Order:
A B C D E F G H I D E F G H I D E H I J
Related puzzles: