2D Array Access in C

Level 389 keystrokes

Declares a 2D array and accesses specific elements using row and column indices.

C code

// 2 rows of 3 columns; each inner { } fills one row
1int matrix[2][3] = {{1, 2, 3}, {4, 5, 6}};
// Row index first, both from 0: matrix[0][1] is 2 and matrix[1][2] is 6
2printf("%d %d\n", matrix[0][1], matrix[1][2]);

Output

2 6
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.

  • ,× 7
  • [× 6
  • ]× 6
  • {× 3
  • }× 3
  • ;× 2
  • "× 2
  • %× 2
  • (× 1
  • )× 1

More C examples at level 3

← C typing practice