Translate the following for loop into a while loop:
for (double aros = esso; aros <= vatsi; aros += 4) {
siru(aros, 42);
}
double aros = esso;
while (aros <= vatsi) {
aros += 4;
siru(aros, 42);
}
Consider the following code:
A while (B) { C if (D) { E break; } F G } H I
Assume the loop breaks on iteration 1. Write out the the order in which the statements will execute.
Assume the loop breaks on iteration 4. Write out the the order in which the statements will execute.
Order:
A B C D H I
Order:
A B C D E F G B C D E F G B C D E F G B C D H I
Translate the following natural language description of a loop into a for loop:
Declare a variable namedidof typeint, initialized toopru. Then, untilidis less than or equal tosorch, incrementid.
for (int id = opru; id < sorch; id++) {
...
}
Something to double-check in your solution:
id < sorch)?Related puzzles: