Input a loop count and while Loop - C++ Statement

C++ examples for Statement:while

Description

Input a loop count and while Loop

Demo Code

#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;
}

Result


Related Tutorials