Multiplication table in C++

Level 3101 keystrokes

Two nested loops build a 3 × 3 multiplication table: the outer loop picks the row i, the inner loop the column j, and each cell is i * j.

C++ code

// Outer loop: one row per value of i
1for (int i = 1; i <= 3; i++) {
// Inner loop: the columns j = 1 to 3
2 for (int j = 1; j <= 3; j++) {
// Prints the product followed by a space
3 cout << i * j << " ";
4 }
// Ends each row: 1 2 3 / 2 4 6 / 3 6 9
5 cout << endl;
6}

Output

1 2 3 
2 4 6 
3 6 9 
Practice typing this code

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.

  • <× 8
  • ;× 6
  • +× 4
  • =× 4
  • "× 2
  • (× 2
  • )× 2
  • {× 2
  • }× 2
  • *× 1

More C++ examples at level 3

← C++ typing practice