Use do while loop to read a number : do while « Operators statements « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int main() 
{ 
  int num; 
 
  do { 
    cout << "Enter a number (100 to stop): "; 
    cin >> num; 
  } while(num != 100); 
 
  return 0; 
}
Enter a number (100 to stop): 1
Enter a number (100 to stop): 2
Enter a number (100 to stop): 3
Enter a number (100 to stop): 100








3.17.do while
3.17.1.do while loop with int counter
3.17.2.Use do while loop to read a number
3.17.3.Nested if statement in a do while loop
3.17.4.An improved Help system that uses a do-while to process a menu selection