← IGCSE Computer Science Paper 2

Parallel arrays

Two or more arrays of the same size where the same index holds related data, e.g. StudentNames[3] and Marks[3] both describe the same student.

Understanding Parallel arrays in IGCSE Computer Science Paper 2

What it does: The single loop variable Index fills the name and the mark for the same student on each pass. Parallel arrays are separate 1D arrays linked by index. A grid of rows and columns is a 2D array. A parallel array to a 30-element StudentNames array must also have bounds 1 to 30, but it can hold a different data type.

Common mistakes: Parallel arrays must use the same index for the same student. Marks[I+1] shows the next student's mark next to this name. It should be Marks[I]. Both arrays hold 5 items, so the loop must stop at 5. Going to 6 uses an index that does not exist in either array. It should be FOR I ← 1 TO 5.

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 459–468) and word search (Modules 459–478).

Take this worksheet further — free with Cloodit

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

Learning
Duo
StudentNames[4] holds "Mia". Which element of Marks holds Mia's mark if the arrays are parallel?
Marks[4]Marks[5]
Matches
DECLARE StudentNames : ARRAY[1:30] OF STRING DECLARE Marks : ARRAY[1:25] OF INTEGER
↓
The arrays have different lengths (30 and 25), so some students would have no matching mark and the indexes would not line up.
Applying
Meanings
Term
parallel arrays
Meaning
Two or more arrays of the same size where the same index holds related data, e.g. StudentNames[3] and Marks[3] both describe the same student.
Practice
DECLARE StudentNames : ARRAY[1:3] OF STRING
Testing
Gaps
DECLARE StudentNames : ARRAY[1:5] OF
Check Answer
Spots
3 INPUT Marks[I]
4 OUTPUT Names[I], Marks[I+1]

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

The 'Manta Ray' badge — Graceful 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. StudentNames[4] holds "Mia". Which element of Marks holds Mia's mark if the arrays are parallel?
A. Marks[5]
B. Marks[4] ✓
In parallel arrays the same index refers to the same item, so Mia's name and mark are both at index 4.
2. Which statement describes parallel arrays?
A. Two arrays of the same size where the same index holds related data ✓
B. One array whose elements are stored in two rows and two columns
Parallel arrays are separate 1D arrays linked by index. A grid of rows and columns is a 2D array.
3. Which loop reads a name and a mark for each student into parallel arrays (indexes 1 to 30)?
A. FOR Index ← 1 TO 30 INPUT StudentNames[Index] INPUT Marks[Index + 1] NEXT Index
B. FOR Index ← 1 TO 30 INPUT StudentNames[Index] INPUT Marks[Index] NEXT Index ✓
One loop can fill both arrays, but it must use the same index for both so the related values stay together.
4. A school stores names in StudentNames and marks in Marks. Which pair of declarations suits parallel arrays?
A. ARRAY[1:30] OF STRING and ARRAY[1:30] OF INTEGER ✓
B. ARRAY[1:30] OF STRING and ARRAY[1:20] OF INTEGER
Parallel arrays must have the same length so every index in one array has a matching element in the other. They can have different data types.
5. Can parallel arrays store different data types, such as STRING names and INTEGER marks?
A. Yes, each array has one type but the arrays can differ ✓
B. No, all parallel arrays must use the same data type
Each array holds one data type, but separate arrays can use different types, which lets them store one record's details.

Match the Pairs

OUTPUT StudentNames[3], Marks[3] → Displays the name and the mark of the same student, because index 3 is used in both parallel arrays.
DECLARE Marks : ARRAY[1:30] OF INTEGER → Declares an INTEGER array with 30 elements that can sit beside a 30-element names array, so each index matches one student.
One loop can read both parallel arrays, because the same index refers to the same student in each array. → FOR Index ← 1 TO 30 INPUT StudentNames[Index] INPUT Marks[Index] NEXT Index
Parallel arrays can hold different data types for one record, such as STRING names and INTEGER marks. → DECLARE StudentNames : ARRAY[1:30] OF STRING DECLARE Marks : ARRAY[1:30] OF INTEGER
DECLARE StudentNames : ARRAY[1:30] OF STRING DECLARE Marks : ARRAY[1:25] OF INTEGER → The arrays have different lengths (30 and 25), so some students would have no matching mark and the indexes would not line up.
OUTPUT StudentNames[3], Marks[4] → Different indexes are used, so the name of student 3 is shown with the mark of student 4, which are not related.

Key Term

parallel arrays
Two or more arrays of the same size where the same index holds related data, e.g. StudentNames[3] and Marks[3] both describe the same student.

Fill in the Blanks

1. DECLARE StudentNames : ARRAY[1:5] OF STRING
Hint: Type the data type that suits an array of student names.
2. DECLARE Marks : ARRAY[1:5] OF INTEGER
Hint: Type the data type that suits whole-number marks.
3. OUTPUT StudentNames[Index], Marks[Index]
Hint: Type the variable that picks the same position as in the first array.
4. DECLARE StudentNames : ARRAY[1:30] OF STRING DECLARE Marks : ARRAY[1:30] OF INTEGER
Hint: Type the upper bound that keeps both arrays the same length.
5. FOR Index ← 1 TO 30 OUTPUT StudentNames[Index], Marks[Index] NEXT Index
Hint: Type the loop variable that closes the FOR loop.

Spot the Error

Question 1
A FOR I ← 1 TO 3
B INPUT Names[I]
C INPUT Marks[I]
D OUTPUT Names[I], Marks[I+1]
E NEXT I
Line D — Parallel arrays must use the same index for the same student. Marks[I+1] shows the next student's mark next to this name. It should be Marks[I].
Question 2
A // 5 students in each array
B FOR I ← 1 TO 6
C OUTPUT Names[I]
D OUTPUT Marks[I]
E NEXT I
Line B — Both arrays hold 5 items, so the loop must stop at 5. Going to 6 uses an index that does not exist in either array. It should be FOR I ← 1 TO 5.
Question 3
A Names[1] ← "Ava"
B Marks[1] ← 88
C Passed[1] ← "TRUE"
Line C — Passed is a BOOLEAN array, so it can only store TRUE or FALSE, not a STRING. The quotes must be removed: Passed[1] ← TRUE.
Question 4
A FOR I ← 1 TO 3
B OUTPUT Names[I]
C OUTPUT Marks[I]
D NEXT J
Line D — The loop counter is I, so the loop must end with NEXT I. NEXT J names a variable that is not the loop counter, so the same index would not be used for both arrays.
Question 5
A FOR I ← 1 TO 5
B IF Names[I] = "Zoe" THEN
C OUTPUT Names[I]
D ENDIF
E NEXT I
Line C — Once Zoe is found at index I, her mark is in the parallel array at the same index. It should output Marks[I], not Names[I], which just repeats her name.

Student with a class code? Join your class →