Normally, the two – dimensional array can be viewed as a matrix. The conceptual view of a 2 – D array is shown below:
int A[4][3];
A[0][0] |
A[0][1] |
A[0][2] |
A[1][0] |
A[1][1] |
A[1][2] |
A[2][0] |
A[2][1] |
A[2][2] |
A[3][0] |
A[3][1] |
A[3][2] |
In the above example, the 2 – D array name A has 4 rows and 3 columns.
Like one – dimensional, the 2 – D array elements are stored in continuous memory. There are two types of 2 – D array memory representations.
They are:
1. Row – Major order
2. Column – Major order
For example
intA[4][3] = {
{8,6,5},
{2,1,9},
{3,6,4},
{4,3,2},
Row major:
Column major order