SLIDE 1
CSZone.co.uk
Click to advance · Arrow keys also work
AQA 8525 · Section 3.2 · 3.2.6b

2D Arrays
Rows & Columns

Declaring 2D Arrays · Indexing · Nested Loops

CSZoneAQA GCSE Computer Science 8525
From 1D to 2D

What is a 2D Array?

A 2D array is a grid of values with rows and columns. You need two index values to access an element: [row][column]. Think of it like a spreadsheet or seating plan.
grid = [ [1,2,3], [4,5,6], [7,8,9] ] ← 3 rows, 3 columns
1
2
3
4
5
6
7
8
9
← row 0
← row 1
← row 2
grid[1][1] = 5 (row 1, column 1)
AQA 2D Array Syntax

Declaring and Accessing 2D Arrays

DECLARING
grid ← [[1,2,3],
         [4,5,6],
         [7,8,9]]
READING & WRITING
OUTPUT grid[0][2]
← 3

grid[2][0] ← 99

x ← grid[1][1]
← x = 5
Traversing 2D Arrays

Nested FOR Loops

grid ← [[1,2,3],[4,5,6],[7,8,9]]

FOR row ← 0 TO 2
  FOR col ← 0 TO 2
    OUTPUT grid[row][col]
  ENDFOR
ENDFOR
Pattern:Outer loop = rows. Inner loop = columns. Total iterations = rows × columns.
Exam Practice

Have a go at this question

AQA-style question
A 2D array called seats is defined: [[True,False],[False,True],[True,True]]. Write pseudocode to output the value at row 2, column 0, then change it to False.
2 marks
OUTPUT seats[2][0] ← True
seats[2][0] ← False
Key Takeaways

What to Remember

2D arrays store data in rows and columns — like a grid
Access with two indices: array[row][column] — both start at 0
Traverse with nested FOR loops — outer for rows, inner for columns
Real uses: game boards, seating plans, timetables, spreadsheet data