C++ examples for Statement:while
Input a loop count and while Loop
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszArgs[]) { int nLoopCount; cout << "Enter loop count: "; cin >> nLoopCount;/*w w w . j a v a 2 s . c om*/ while (nLoopCount > 0) { nLoopCount = nLoopCount - 1; cout << "Only " << nLoopCount << " loops to go" << endl; } return 0; }