A 2D array is a grid: one index picks the row, the other picks the column — boards, matrices and tables.
1 A grid of cells
int grid[2][3] reserves 2 rows x 3 columns — six ints in one block.
2 Two indexes
grid[row][col] — both count from 0, so grid[1][2] is row 1, column 2.
3 Nested loops
The outer loop walks the rows; the inner loop walks the columns of each row.
4 Row-major memory
The grid flattens in memory: row 0 stored first, then row 1 — one continuous line.
5 Where you will use it
Game boards, matrices, spreadsheets, images — all of them are grids.
A grid of cells
A grid of cells1int grid[2][3] reserves 2 rows x 3 columns — six ints in one block. Two indexes2grid[row][col] — both count from 0, so grid[1][2] is row 1, column 2.
Nested loops3The outer loop walks the rows; the inner loop walks the columns of each row. Row-major memory4The grid flattens in memory: row 0 stored first, then row 1 — one continuous line. Where you will use it5Game boards, matrices, spreadsheets, images — all of them are grids. 5 building blocks make up A grid of cells
Six cells, one block — the grid flattens into row-major order. Drag to orbit, then play the script.
Drag to orbit the scene. Press Play to watch memory in action.
Press play — the outer loop picks a row, the inner loop crosses it, cell by cell.
mainThe OS calls main() — execution begins.
Memory
no variables yet — press play
Console
output appears as the program runs…
Click a term, then click its description to lock the pair.
4 conceptsTap a card to expand ?grid[2][3]drops into place
?grid[1][0]drops into place
?nested loopsdrops into place
?row-majordrops into place
Three lookups into one table — mind which index is the row.
Your predicted output — one line per console line
Hint: First index picks the row, second the column — t[1][0] is row 1, column 0, which holds 7.
01int grid[2][3] means 2 rows, 3 columns, 6 cells in one memory block.
02grid[r][c]: row first, column second — both indexes start at 0.
03Nested loops fill or read a grid: outer = rows, inner = columns.
04Memory stores a 2D array row after row — that is row-major order.