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 ok of type int, initialized to 10. Then, until ok is less than toEdi, divide ok by 2.

Solution

for (int ok = 10; ok <= toEdi; ok /= 2) {
    ...
}

Something to double-check in your solution:


Related puzzles: