C++ examples for Statement:for
Print the numbers 1-5 three times. using a nested loop.
#include <iostream> using namespace std; int main()/*from w ww . ja v a 2 s. co m*/ { int times, num; // Outer and inner for loop variables for (times=1; times<=3; times++) { for (num=1; num<=5; num++) { cout << num; } // Inner loop body cout << "\n"; } // End of outer loop return 0; }