Mega Code Archive

 
Categories / C++ Tutorial / Operators Statements
 

Do while loop with int counter

#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 counter is: 0