- To create a 2D array of integers
int matrix[2][3] = { {1, 4, 2}, {3, 6, 8} };| C code 2D matrix |
|||
| Column 0 | Column 1 | Column 2 | |
| Row 0 | 1 | 4 | 2 |
| Row 1 | 3 | 6 | 8 |
- Access the Elements of a 2D Array
int matrix[2][3] = { {1,4,2}, {3,6,8}};
printf("%d", matrix[0][2]); // Outputs 2