Mega Code Archive

 
Categories / C++ Tutorial / Operators Statements
 

Skip the body of the while loop when the condition is false

#include <iostream>    int main()  {      int counter = 3;      while (counter > 0)      {          std::cout << "Hello!\n";          counter--;      }      std::cout << "counter is OutPut: " << counter;      return 0;  } Hello! Hello! counter is OutPut: 0