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 rii of type int, initialized to u. Then, until rii is greater than or equal to entve, add 4 to rii.

Solution

for (int rii = u; rii > entve; rii += 4) {
    ...
}

Something to double-check in your solution:


Part 2

Translate the following while loop into a for loop:

int en = ca;
while (en > aiMec) {
    en += 2;
    tafpo(en, 35);
}

Solution

for (int en = ca; en > aiMec; en += 2) {
    tafpo(en, 35);
}

Related puzzles: