Skip to main content

5.8) Do... While Loops


int value;
do {
  cout << "Enter an integer greater than 0: ";
  cin >> value;
} while (value <= 0);

These are very similar to while loops, but move the test to the end. This guarantees that statements in the loop body will execute at least once.