A 3 x 4 matrix is 3 rows of 4 values, but memory is one flat line. Row-major order stores row 0, then row 1, and so on, so cell (r, c) sits at flat index r x 4 + c. Walk it in that order.
Walking a 3 by 4 matrix in row-major order and naming the flat index of each cell.
(0, 0) holds 1. Flat index 0 x 4 + 0 = 0.
Cell 0, 0 is flat index 0.
(0, 1) holds 2. Flat index 0 x 4 + 1 = 1.
Cell 0, 1 is flat index 1.
(0, 2) holds 3. Flat index 0 x 4 + 2 = 2.
Cell 0, 2 is flat index 2.
(0, 3) holds 4. Flat index 0 x 4 + 3 = 3.
Cell 0, 3 is flat index 3.
(1, 0) holds 5. Flat index 1 x 4 + 0 = 4.
Cell 1, 0 is flat index 4.
(1, 1) holds 6. Flat index 1 x 4 + 1 = 5.
Cell 1, 1 is flat index 5.
(1, 2) holds 7. Flat index 1 x 4 + 2 = 6.
Cell 1, 2 is flat index 6.
(1, 3) holds 8. Flat index 1 x 4 + 3 = 7.
Cell 1, 3 is flat index 7.
(2, 0) holds 9. Flat index 2 x 4 + 0 = 8.
Cell 2, 0 is flat index 8.
(2, 1) holds 10. Flat index 2 x 4 + 1 = 9.
Cell 2, 1 is flat index 9.
(2, 2) holds 11. Flat index 2 x 4 + 2 = 10.
Cell 2, 2 is flat index 10.
(2, 3) holds 12. Flat index 2 x 4 + 3 = 11.
Cell 2, 3 is flat index 11.
12 cells, flat indices 0 to 11. Walking row by row touches memory in order, which is why row-major loops run faster than column-major ones on a row-major matrix.
All 12 cells visited in row-major order.