C++ Code Example: double nested for-loop

Here the product of the individual loop elements is output in a double nested loop.

#include <iostream>
using namespace std;

int main() {
    for (int i = 3; i < 5; i++) {
        for (int j = 1; j < 10; j++) {
            for (int k = 1; k < 5; k++) {
                int result = i * j * k;
                cout << result << " ";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}
Output
3 6 9 12 
6 12 18 24 
9 18 27 36 
12 24 36 48 
15 30 45 60 
18 36 54 72 
21 42 63 84 
24 48 72 96 
27 54 81 108 

4 8 12 16 
8 16 24 32 
12 24 36 48 
16 32 48 64 
20 40 60 80 
24 48 72 96 
28 56 84 112 
32 64 96 128 
36 72 108 144