do while loop with int counter : do while « Operators statements « C++ Tutorial






#include <iostream>
 
 int main()
 {
     int counter;
     std::cout << "How many hellos? ";
     std::cin >> counter;
     do
     {
         std::cout << "Hello\n";
         counter--;
     } while (counter >0 );
     std::cout << "counter is: " << counter << std::endl;
     return 0;
 }
How many hellos? 5
Hello
Hello
Hello
Hello
Hello
counter is: 0








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