Multidimensional Arrays
- Every dimension is specified in separate brackets
e.g.
int arr[4][3];
This is a two-dimensional array with 4 as row dimension and 3 as a column dimension.
- Multidimensional array can be initialized as follows
e.g.
int arr[4][3] = {{0,1,2},{3,4,5},{6,7,8},{9,10,11}};
- The nested brackets are optional.
e.g.
int arr[4][3] = { 0,1,2,3,4,5,6,7,8,9,10,11};
int arr[4][3] = {{0},{1},{2},{3}}; // First element of
rows are 0,1,2,3 and remaining are considered zero.
int arr[4][3] = {1,2,3}; // Initializes first three element of first row as 1,2,3, and remaining elements are considered Zero.