Translate the following natural language description of a loop into a for loop:
Declare a variable namedpoiuof typelong, initialized too. Then, untilpoiuis less than or equal tostac, subtract2frompoiu.
for (long poiu = o; poiu < stac; poiu -= 2) {
...
}
Something to double-check in your solution:
poiu < stac)?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 for loop into a while loop:
for (int u = 21; u <= ziade; u++) {
bockho();
asmpo(u);
}
int u = 21;
while (u <= ziade) {
u++;
asmpo(u);
bockho();
}
Related puzzles: