Do while loops - C++ Statement

C++ examples for Statement:do while

Description

Do while loops

Demo Code

#include <iostream> 
 #include <stdlib.h> 

 using namespace std; 

 int main(int argc, char *argv []) 
 { //from  w w  w. j  a v  a2  s .  c om
     int anInt; 

     // Prompt the user for an integer. 
     cout << "Please input an integer and press Enter: "; 

     // Get the integer. 
   cin >> anInt; 

     int i=0; 
     do 
     { 
         cout << i++ << endl; 
     } while (i < anInt); 

     return 0; 
}

Result


Related Tutorials