C++ examples for Statement:for
Define for loop control variable inside for statement
#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; } }