Define for loop control variable inside for statement - C++ Statement

C++ examples for Statement:for

Description

Define for loop control variable inside for statement

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;/*from   ww  w  . ja  va2  s.  co  m*/

    for (int i = 1; i <= nLoopCount; i++)
    {
        cout << "We've finished " << i << " loops" << endl;
    }
}

Result


Related Tutorials