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 ulro of type int, initialized to unsu. Then, until ulro is greater than or equal to saor, divide ulro by 2.

Solution

for (int ulro = unsu; ulro > saor; ulro /= 2) {
    ...
}

Something to double-check in your solution:


Related puzzles: