← IGCSE Computer Science Paper 2

Array, element and index

A fixed-length structure of elements; each element holds one value and is reached by its index, the position number in square brackets, such as Marks[3].

Understanding Array, element and index in IGCSE Computer Science Paper 2

What it does: Marks[2] is a single element, so this stores one value (75) at index 2. One array name with different indexes replaces separate variables such as Mark1, Mark2 and Mark3. Pseudocode uses square brackets around the index, so Scores[5] is correct. Index numbers are consecutive, so each one goes up by 1 with no gaps. Arrays have a fixed length. The number of elements is set when the array is declared. The array has only 5 elements, so every index must be between 1 and 5.

Common mistakes: The index of an array element goes in square brackets, not round brackets. It should be Marks[3] ← 64. Each element is reached by its index, so the position number must be written inside the square brackets. It should be Age[1] ← 15.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 439–448) and word search (Modules 439–458).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which statement describes an array?
A fixed-length structure that holds several elements under one nameA single variable that holds exactly one value
Matches
Marks(3) ← 60
↓
Round brackets are used for the index. The index must go in square brackets, as in Marks[3].
Applying
Meanings
Term
ARRAY
Meaning
A fixed-length structure of elements; each element holds one value and is reached by its index, the position number in square brackets, such as Marks[3].
Practice
DECLARE Marks : ARRAY[1:5] OF INTEGER
Testing
Gaps
DECLARE Marks : [1:5] OF INTEGER
Check Answer
Spots
2Marks[2] ← 85
3Marks(3) ← 64

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Golden Eagle' badge — High Flyer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which statement describes an array?
A. A single variable that holds exactly one value
B. A fixed-length structure that holds several elements under one name ✓
An array stores many elements under one identifier. A single variable stores only one value.
2. In Marks[3], what is the 3?
A. The index: the position of the element ✓
B. The value stored in the element
The number in square brackets is the index. It shows which element to use. The value stored there can be anything.
3. Which line reads element number 5 of the array Scores?
A. Scores[5] ✓
B. Scores(5)
Pseudocode uses square brackets around the index, so Scores[5] is correct.
4. What is an element of an array?
A. The whole array with all its values
B. One stored value at a single index ✓
An element is one value in the array. It is reached by its index.
5. Which set of index numbers could belong to an array?
A. 1, 2, 3, 4, 5 ✓
B. 1, 3, 8, 20, 21
Index numbers are consecutive, so each one goes up by 1 with no gaps.

Match the Pairs

Marks[3] → The element at index 3 of the array Marks; the index is the position number in square brackets
DECLARE Marks : ARRAY[1:5] OF INTEGER → Creates one array of 5 elements with consecutive indexes 1, 2, 3, 4, 5, each holding an integer
An element is one stored value, and it is reached by giving its index → Marks[2] ← 75
An array is better than separate variables because one name holds many values that are reached by index → Marks[1], Marks[2], Marks[3]
Marks(3) ← 60 → Round brackets are used for the index. The index must go in square brackets, as in Marks[3].
Marks[6] ← 60 (array declared as ARRAY[1:5]) → Index 6 does not exist because the array has a fixed length and its indexes only run from 1 to 5.

Key Term

ARRAY
A fixed-length structure of elements; each element holds one value and is reached by its index, the position number in square brackets, such as Marks[3].

Fill in the Blanks

1. DECLARE Marks : ARRAY[1:5] OF INTEGER
Hint: Type the keyword that declares a fixed-length structure holding many elements.
2. DECLARE Marks : ARRAY[1:5] OF INTEGER Marks[5] ← 90
Hint: Type the index number of the last element in the array declared above.
3. Marks[1] ← 60 Marks[2] ← 71 Marks[3] ← 84
Hint: Type the next consecutive index number in the sequence.
4. DECLARE Scores : ARRAY[1:3] OF INTEGER Scores[2] ← 14
Hint: Type the array identifier that was declared on the first line.
5. Total ← Marks[1] + Marks[2]
Hint: Type the operator that adds the values stored in two elements.

Spot the Error

Question 1
A Marks[1] ← 70
B Marks[2] ← 85
C Marks(3) ← 64
D OUTPUT Marks[2]
Line C — The index of an array element goes in square brackets, not round brackets. It should be Marks[3] ← 64.
Question 2
A Age[] ← 15
B Age[2] ← 16
C OUTPUT Age[1]
Line A — Each element is reached by its index, so the position number must be written inside the square brackets. It should be Age[1] ← 15.
Question 3
A // Prices: indexes 1 to 3
B Prices[0] ← 4.5
C Prices[2] ← 6
D OUTPUT Prices[2]
Line B — The comment says the indexes run from 1 to 3, so index 0 does not exist in this array. The first element is Prices[1] ← 4.5.
Question 4
A Names[1] ← "Ali"
B Names[2] ← "Bea"
C Names[3] ← "Cy"
D OUTPUT Names["Cy"]
Line D — The index must be a whole number giving the position of the element, not the value stored in it. It should be OUTPUT Names[3].
Question 5
A Temp[1] ← 18, 21
B Temp[2] ← 21
C OUTPUT Temp[1] + Temp[2]
Line A — Each element holds only one value, so you cannot store 18 and 21 in Temp[1]. Use a separate element for each value, such as Temp[1] ← 18 and Temp[2] ← 21.

Student with a class code? Join your class →