C++ examples for Statement:for
Create nested for loop
#include <iostream> using namespace std; int main()//from www.jav a 2 s .c om { const int MAXI = 5; const int MAXJ = 4; int i, j; for (i = 1; i <= MAXI; i++) // start of outer loop { cout << "\ni is now " << i << endl; for (j = 1; j <= MAXJ; j++) // start of inner loop cout << " j = " << j; // end of inner loop } // end of outer loop cout << endl; return 0; }