While loops and for loops: Correct Solution


Part 1

Translate the following natural language description of a loop into a for loop:

Declare a variable named em of type long, initialized to 97. Then, until em is greater than or equal to diOsh, increment em.

Solution

for (long em = 97; em > diOsh; em++) {
    ...
}

Something to double-check in your solution:


Part 2

Translate the following for loop into a while loop:

for (short pudo = ple; pudo > icIl; pudo--) {
    dishzi(pudo);
}

Solution

short pudo = ple;
while (pudo > icIl) {
    pudo--;
    dishzi(pudo);
}

Related puzzles: