Nested for loops in C++
Level 3109 keystrokes
The outer loop runs i from 1 to 3 and, for each i, the inner loop runs j from 1 to 2. Each row prints the pairs i,j and then ends the line.
C++ code
// Outer loop: one row for each i (1 to 3)1for (int i = 1; i <= 3; i++) { // Inner loop: runs completely for each i, with j = 1 and 22 for (int j = 1; j <= 2; j++) { // Prints a pair such as 1,1 followed by a space3 cout << i << "," << j << " ";4 } // After the inner loop, ends the row: 1,1 1,2 / 2,1 2,2 / 3,1 3,25 cout << endl;6}Output
1,1 1,2 2,1 2,2 3,1 3,2
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 12;× 6"× 4+× 4=× 4(× 2)× 2{× 2}× 2,× 1