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 re of type short, initialized to ed. Then, until re is less than cecu, increment re.

Solution

for (short re = ed; re <= cecu; re++) {
    ...
}

Something to double-check in your solution:


Part 2

Translate the following for loop into a while loop:

for (double dus = phia; dus < qoer; dus *= 4) {
    belcad(dus);
}

Solution

double dus = phia;
while (dus < qoer) {
    dus *= 4;
    belcad(dus);
}

Related puzzles: