Consider the following code:
A for (B; C; D) { E } F G
Assume the body of the loop executes 1 time. 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 D E D F G
Order:
A B C D E C D E D F G
Translate the following natural language description of a loop into a for loop:
Declare a variable namedaof typelong, initialized topras. Then, untilais less thannenwi, add2toa.
for (long a = pras; a <= nenwi; a += 2) {
...
}
Something to double-check in your solution:
a <= nenwi)?Translate the following while loop into a for loop:
int pse = ca;
while (pse <= sqe) {
pse++;
pecmen(pse);
}
for (int pse = ca; pse <= sqe; pse++) {
pecmen(pse);
}
Related puzzles: