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 ad of type long, initialized to 1. Then, until ad is greater than or equal to cim, multiply ad by 2.

Solution

for (long ad = 1; ad > cim; ad *= 2) {
    ...
}

Something to double-check in your solution:


Related puzzles: