📁 Paper 1 · 3.2 Programming
3.2.2d Arrays
AQA 8525 · GCSE Computer Science · ~12 min read
Notes
──
Video
──
Worksheet
──
Quiz

What is an Array?

An array is a data structure that stores multiple values of the same data type under a single variable name. Each value is accessed by its index (position).

AQA arrays are zero-indexed — the first element is at index 0.

1D Arrays (One-dimensional)

// Declaring a 1D array scores ← [85, 72, 91, 64, 78] // Accessing elements — index starts at 0 OUTPUT scores[0] // 85 OUTPUT scores[2] // 91 OUTPUT scores[4] // 78 // Updating an element scores[1] ← 75 // changes 72 to 75

Traversing an Array with a FOR Loop

// Output all scores FOR i ← 0 TO 4 OUTPUT scores[i] ENDFOR // Find the total total ← 0 FOR i ← 0 TO 4 total ← total + scores[i] ENDFOR OUTPUT total // 390

2D Arrays (Two-dimensional)

A 2D array is like a grid (table) — accessed with two indices: row and column.

// 3x3 grid of integers grid ← [[1,2,3],[4,5,6],[7,8,9]] OUTPUT grid[0][0] // 1 (row 0, col 0) OUTPUT grid[1][2] // 6 (row 1, col 2) OUTPUT grid[2][1] // 8 (row 2, col 1) // Traverse entire 2D array FOR row ← 0 TO 2 FOR col ← 0 TO 2 OUTPUT grid[row][col] ENDFOR ENDFOR

Common Array Operations

OperationExample
Declarenames ← ["Alice","Bob","Carol"]
Accessnames[0] → "Alice"
Updatenames[1] ← "Beth"
TraverseFOR i ← 0 TO 2 ... ENDFOR
SearchIF scores[i] == target THEN

Why Use Arrays?

  • Store many values of the same type without naming each separately
  • Process them efficiently with loops
  • Example: storing 30 students' marks — far better than 30 separate variables
Exam tip: AQA arrays start at index 0. For a 5-element array, valid indices are 0–4. The last index = length − 1. Always use a FOR loop from 0 TO length-1 to traverse.
⚠️ Common Mistakes
  • Starting the index at 1 instead of 0 — AQA arrays are zero-indexed
  • Off-by-one errors: FOR i ← 0 TO 5 on a 5-element array accesses index 5 which doesn't exist
  • Confusing row and column order in 2D arrays: grid[row][col]
Video coming soon

Key points

  • Arrays store multiple values under one name
  • Zero-indexed — first element at index 0
  • 1D arrays and 2D arrays (grids)
  • Traversing arrays with FOR loops
Click slide or press arrow keys to navigate
✍️

Worksheet — 3.2.2d Arrays

8 questions · 25 marks

Q1What is an array? State two advantages over using separate variables.[3]
✅ Mark scheme
Mark scheme
Array: stores multiple values of the same type under one name [1]. Advantages: can process all elements with a loop [1]; saves having to name each variable separately [1].
Q2Given: nums ← [10, 20, 30, 40, 50]. State the value of: (a) nums[0] (b) nums[3] (c) nums[4][3]
✅ Mark scheme
Mark scheme
(a) 10 [1]; (b) 40 [1]; (c) 50 [1].
Q3Write a FOR loop to output all values in: scores ← [65, 78, 82, 90, 55, 74][3]
✅ Mark scheme
Mark scheme
FOR i ← 0 TO 5 [1]; OUTPUT scores[i] [1]; ENDFOR [1].
Q4Given: grid ← [[1,2],[3,4],[5,6]]. State the value of: (a) grid[0][1] (b) grid[2][0] (c) grid[1][1][3]
✅ Mark scheme
Mark scheme
(a) 2 [1]; (b) 5 [1]; (c) 4 [1].
Q5Write pseudo-code to find and output the largest value in: vals ← [3, 9, 1, 7, 4][4]
✅ Mark scheme
Mark scheme
largest ← vals[0] [1]; FOR i ← 1 TO 4 [1]; IF vals[i] > largest THEN largest ← vals[i] [1]; ENDFOR; OUTPUT largest [1].
Q6What is wrong with: FOR i ← 1 TO 5, OUTPUT scores[i], ENDFOR — when scores has 5 elements?[2]
✅ Mark scheme
Mark scheme
Starts at index 1, missing scores[0] [1]; ends at index 5 which doesn't exist (valid indices 0–4), causing an out-of-bounds error [1].
Q7Write pseudo-code to count how many values in scores ← [65, 78, 82, 90, 55, 74] are greater than 70.[4]
✅ Mark scheme
Mark scheme
count ← 0 [1]; FOR i ← 0 TO 5 [1]; IF scores[i] > 70 THEN count ← count + 1 [1]; ENDFOR; OUTPUT count [1].
Q8Describe how you would use a 2D array to store the scores of 3 students across 4 tests. State the index notation to access student 2, test 3.[3]
✅ Mark scheme
Mark scheme
3x4 2D array where row = student, column = test [1]; e.g. scores ← [[s1t1,s1t2,s1t3,s1t4],[...],[...]] [1]; scores[1][2] accesses student 2 test 3 (zero-indexed) [1].
Check your answers above.
Topic Quiz
Q 1 of 10
You scored
out of 10
Card 1 of 5
Click to flip
🎉
All done!
TermDefinition
🎯

Mini Test — 3.2.2d Arrays

Timed exam conditions.

  • 8 questions · 10 minutes
  • 5 MCQ + 3 short answer
← 3.2.2c Iteration
13 of 57 · AQA 8525
3.2.3 String Handling →