A bi-dimensional array memory access follows a row-major pattern when iterating over the rows sequentially, then doing the same for each column within the row.
for (i=0; i<ROWS; ++i) {
for (j=0; j<COLS; ++j) {
A[i][j]= …
}
}
Note in the pseudocode that the outer loop drives the first dimension of the array while the inner loop drives the second dimension.