← IGCSE Computer Science Paper 2

Why arrays are used

An array stores many values of the same type under one name, so you need one array instead of many variables. An index reaches each value, and loops can process them all.

Understanding Why arrays are used in IGCSE Computer Science Paper 2

What it does: The array name Names plus the index 7 picks out exactly one stored value, so no separate variable name is needed. A FOR loop can use the index to visit every element, so one short block of code can handle all of the values. An array with a loop replaces 100 repeated statements with a few lines. Arrays make programs easier to change. You only update the bounds, not add many new variables. All the elements in an array must be the same data type. Related values of the same kind belong in one array under one meaningful identifier.

Common mistakes: A value is stored in an array element with the assignment arrow ←, not =. It should be Name[2] ← "Liam". An array name on its own does not reach one value. The index is needed so each pass of the loop displays one element: OUTPUT Name[i].

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
A teacher wants to store 30 student names in a program. Which approach is better?
30 separate variables: Name1, Name2, Name3 ... Name30One array: DECLARE Names : ARRAY[1:30] OF STRING
Matches
DECLARE Name1 : STRING DECLARE Name2 : STRING DECLARE Name3 : STRING (repeated for 30 students)
↓
Using a separate variable for every student makes the program long and hard to change; one array should be used instead
Applying
Meanings
Term
ARRAY
Meaning
An array stores many values of the same type under one name, so you need one array instead of many variables. An index reaches each value, and loops can process them all.
Practice
DECLARE Names : ARRAY[1:30] OF STRING
Testing
Gaps
DECLARE Names : [1:30] OF STRING
Check Answer
Spots
1Name[1] ← "Ava"
2Name[2] = "Liam"

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

The 'Wolverine' badge — Fearless Coder, 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. A teacher wants to store 30 student names in a program. Which approach is better?
A. 30 separate variables: Name1, Name2, Name3 ... Name30
B. One array: DECLARE Names : ARRAY[1:30] OF STRING ✓
One array holds all 30 names under one name. It is shorter and easier to manage than 30 separate variables.
2. How do you reach one particular value stored in an array?
A. Use the array name with an index, such as Names[5] ✓
B. Give every value its own separate variable name
An array uses one name plus an index to reach each value, so no extra variable names are needed.
3. Which statement about arrays is TRUE?
A. A loop can process every element of an array ✓
B. Each element needs its own line of code to be processed
A FOR loop can use the index to visit every element, so one short block of code can handle all of the values.
4. A program must store 100 test marks. Which design makes the program shorter?
A. 100 variables with 100 INPUT statements
B. One array of 100 INTEGER values and a loop ✓
An array with a loop replaces 100 repeated statements with a few lines.
5. The class grows from 30 to 35 students. Which program is easier to change?
A. The array version: change the upper bound and the loop limit ✓
B. The separate variables version: add five more variables and statements
Arrays make programs easier to change. You only update the bounds, not add many new variables.

Match the Pairs

DECLARE Names : ARRAY[1:30] OF STRING → One array stores 30 student names under a single name
FOR i ← 1 TO 30 OUTPUT Names[i] NEXT i → A loop processes every element of the array using the index
One name and an index reach each value in an array → Names[7]
Without arrays you need a separate variable for every value → Name1, Name2, Name3 ... Name30
DECLARE Name1 : STRING DECLARE Name2 : STRING DECLARE Name3 : STRING (repeated for 30 students) → Using a separate variable for every student makes the program long and hard to change; one array should be used instead
OUTPUT Name1 OUTPUT Name2 OUTPUT Name3 (repeated 30 times) → Writing one OUTPUT per variable does not use a loop; with an array a FOR loop could output every element in a few lines

Key Term

ARRAY
An array stores many values of the same type under one name, so you need one array instead of many variables. An index reaches each value, and loops can process them all.

Fill in the Blanks

1. DECLARE Names : ARRAY[1:30] OF STRING
Hint: Type the keyword that lets one name hold many values of the same type.
2. Names[5] ← "Ava"
Hint: Type the index number of the fifth element in this array.
3. FOR Index ← 1 TO 30 OUTPUT Names[Index] NEXT Index
Hint: Type the loop variable that reaches each element in turn.
4. DECLARE Marks : ARRAY[1:30] OF INTEGER
Hint: Type the data type for whole-number marks stored in every element.
5. FOR Index ← 1 TO 30 Total ← Total + Marks[Index] NEXT Index
Hint: Type the keyword that ends the count-controlled loop so every element is processed.

Spot the Error

Question 1
A Name[1] ← "Ava"
B Name[2] = "Liam"
C Name[3] ← "Mia"
Line B — A value is stored in an array element with the assignment arrow ←, not =. It should be Name[2] ← "Liam".
Question 2
A FOR i ← 1 TO 30
B OUTPUT Name
C NEXT i
Line B — An array name on its own does not reach one value. The index is needed so each pass of the loop displays one element: OUTPUT Name[i].
Question 3
A FOR i ← 1 TO 30
B INPUT Name[i]
C OUTPUT Name[i]
D NEXT j
Line D — NEXT must use the same counter variable as the FOR line. The loop counter is i, so the line should be NEXT i.
Question 4
A FOR i ← 1 TO 30
B INPUT Name[i]
C NEXT i
D OUTPUT Name(1)
Line D — The index of an array element goes in square brackets. One name plus an index reaches each value: Name[1].
Question 5
A Count ← 0
B FOR i ← 1 TO 30
C IF Mark[i] >= 50
D Count ← Count + 1
E ENDIF
F NEXT i
Line C — An IF statement must end its condition line with THEN. It should be IF Mark[i] >= 50 THEN, so one loop can check all 30 marks.

Student with a class code? Join your class →