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 iara of type int, initialized to o. Then, until iara is not equal to cioac, increment iara.

Solution

for (int iara = o; iara != cioac; iara++) {
    ...
}

Something to double-check in your solution:


Part 2

Translate the following while loop into a for loop:

int wors = 85;
while (wors < eshid) {
    wors++;
    shetna(wors);
}

Solution

for (int wors = 85; wors < eshid; wors++) {
    shetna(wors);
}

Related puzzles: