Consider the following code:
A B C while (D) { E F if (G) { H I break; } J K } L M
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 L M
Order:
A B C D E F G H I J K D E F G H I J K D E F G L M
Translate the following natural language description of a loop into a for loop:
Declare a variable namedfiof typeint, initialized todu. Then, untilfiis greater thanmep, subtract3fromfi.
for (int fi = du; fi >= mep; fi -= 3) {
...
}
Something to double-check in your solution:
fi >= mep)?Translate the following for loop into a while loop:
for (double ohel = prap; ohel < anMehus; ohel -= 2) {
ecmor(ohel);
}
double ohel = prap;
while (ohel < anMehus) {
ohel -= 2;
ecmor(ohel);
}
Related puzzles: