Exercise

Do it again: do-while loop

The repeat loop in R is called a do while loop in C++. Compared to a while loop, it moves the condition to the end of the loop, so that the loop contents are guaranteed to be run at least once. The syntax is as follows:

do {
  // Do something
} while(condition);

Notice the semicolon after the while condition.

Instructions

100 XP
  • Initiate the loop with a do statement.
  • Specify the while condition, so the loop keeps iterating while the value of is_good_enough is false.