← IGCSE Computer Science Paper 2

Arrays have a fixed length and one data type

An array has a fixed size set when it is declared, and every element must be the same data type, so STRING and INTEGER cannot be mixed in one array.

Understanding Arrays have a fixed length and one data type in IGCSE Computer Science Paper 2

What it does: One array cannot mix data types, so mixed data is split into parallel arrays, each with a single type and the same size. The bounds 1:10 fix the number of elements at declaration, so the array always holds 10 elements. The size is set when the array is declared. To store more items, you must declare a bigger array. "Pass" is a STRING, but Scores holds INTEGER values only. 72 is an INTEGER so it is allowed. OF STRING makes every element a STRING, and the bounds 1:5 fix the length at 5 elements.

Common mistakes: M is declared as an array of REAL, so every element must be a number. A STRING such as "absent" cannot be stored in it. The line should be M[2] ← 65. N is an array of STRING, so every element must be text. The number 16 is a different data type and cannot be mixed in. The line should be N[2] ← "Liam".

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 student declares DECLARE Scores : ARRAY[1:30] OF INTEGER. How many elements can Scores hold?
30 elements, and the size is fixedAs many as needed, it grows automatically
Matches
DECLARE Data : ARRAY[1:3] OF STRING, INTEGER
↓
An array can only have one data type. You cannot list STRING and INTEGER together. Use two arrays, one for each type.
Applying
Meanings
Term
ARRAY[1:30] OF INTEGER
Meaning
An array has a fixed size set when it is declared, and every element must be the same data type, so STRING and INTEGER cannot be mixed in one array.
Practice
DECLARE StudentName : ARRAY[1:30] OF STRING
Testing
Gaps
DECLARE Scores : ARRAY[1:30] OF
Check Answer
Spots
2M[1] ← 72
3M[2] ← "absent"

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

The 'Fennec Fox' badge — Listener, 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 student declares DECLARE Scores : ARRAY[1:30] OF INTEGER. How many elements can Scores hold?
A. As many as needed, it grows automatically
B. 30 elements, and the size is fixed ✓
The bounds 1 and 30 are set when the array is declared. The array always has 30 elements (30 - 1 + 1) and does not grow.
2. Which declaration is valid in IGCSE pseudocode?
A. DECLARE Marks : ARRAY[1:5] OF INTEGER ✓
B. DECLARE Marks : ARRAY[1:5] OF INTEGER, STRING
An array has only ONE data type after OF. You cannot list two types for the same array.
3. True or false: one array can store the names (STRING) and the ages (INTEGER) of 10 students together.
A. True - an array can mix STRING and INTEGER
B. False - every element must be the same data type ✓
All elements share one data type, so STRING and INTEGER cannot be mixed in one array.
4. A table holds a student's name, age and test mark for 20 students. What is the best way to store it using 1D arrays?
A. Separate arrays: Names (STRING), Ages (INTEGER) and Marks (INTEGER) ✓
B. One array of STRING that holds names, ages and marks mixed
Mixed data needs separate arrays, one per data type or field. Matching index numbers link the values for each student.
5. An array is declared as ARRAY[1:10] OF STRING. What happens if the program needs to store an 11th item?
A. The array cannot hold it - the size was fixed at declaration ✓
B. The array automatically becomes ARRAY[1:11]
The size is set when the array is declared. To store more items, you must declare a bigger array.

Match the Pairs

DECLARE Marks : ARRAY[1:30] OF INTEGER → Creates an array with exactly 30 elements, and every element must be an INTEGER. The size is fixed once declared.
DECLARE Names : ARRAY[1:5] OF STRING → Creates an array that holds exactly 5 STRING values. It cannot store an INTEGER in any element.
A table holds names (STRING) and ages (INTEGER), so you use two separate arrays of the same length, one for each data type. → DECLARE Name : ARRAY[1:20] OF STRING DECLARE Age : ARRAY[1:20] OF INTEGER
The size of an array is set when it is declared. The upper bound 10 means it holds exactly 10 elements and cannot grow. → DECLARE Scores : ARRAY[1:10] OF INTEGER
DECLARE Data : ARRAY[1:3] OF STRING, INTEGER → An array can only have one data type. You cannot list STRING and INTEGER together. Use two arrays, one for each type.
Marks[1] <- "Absent" → Marks is an ARRAY OF INTEGER, so a STRING cannot be stored in it. The value must be an INTEGER such as 0.

Key Term

ARRAY[1:30] OF INTEGER
An array has a fixed size set when it is declared, and every element must be the same data type, so STRING and INTEGER cannot be mixed in one array.

Fill in the Blanks

1. DECLARE Scores : ARRAY[1:30] OF INTEGER
Hint: Type the data type that every one of the 30 elements must share, suited to whole-number scores.
2. // Space for exactly 25 names DECLARE Names : ARRAY[1:25] OF STRING
Hint: Type the upper bound that fixes the size of the array, as stated in the comment.
3. DECLARE Names : ARRAY[1:30] OF STRING DECLARE Marks : ARRAY[1:30] OF INTEGER
Hint: Type the data type for the separate array that holds whole-number marks, since it cannot share the names array.
4. DECLARE Prices : ARRAY[1:10] OF REAL
Hint: Type the keyword that declares a fixed-size list whose elements all have the same data type.
5. // 12 temperatures such as 18.5 and 21.0 DECLARE Temps : ARRAY[1:12] OF REAL
Hint: Type the data type that suits decimal values, which every element of this array will use.

Spot the Error

Question 1
A DECLARE M:ARRAY[1:5] OF REAL
B M[1] ← 72
C M[2] ← "absent"
Line C — M is declared as an array of REAL, so every element must be a number. A STRING such as "absent" cannot be stored in it. The line should be M[2] ← 65.
Question 2
A DECLARE N:ARRAY[1:3] OF STRING
B N[1] ← "Ava"
C N[2] ← 16
D N[3] ← "Zoe"
Line C — N is an array of STRING, so every element must be text. The number 16 is a different data type and cannot be mixed in. The line should be N[2] ← "Liam".
Question 3
A DECLARE T:ARRAY[1:7] OF REAL
B Day ← 1
C WHILE Day <= 8 DO
D T[Day] ← 0.0
E Day ← Day + 1
F ENDWHILE
Line C — The array has a fixed size of 7 elements. A loop that runs while Day is 8 tries to use T[8], which does not exist. The condition should be Day <= 7.
Question 4
A DECLARE N:ARRAY[1:3] OF STRING
B DECLARE S:ARRAY[1:3] OF REAL
C N[1] ← "Ava"
D S[1] ← N[1]
Line D — N[1] holds a STRING, but S is an array of REAL, so it can only hold numbers. Names and marks need separate arrays, each with its own type. The line should be S[1] ← 72.5.
Question 5
A DECLARE G:ARRAY[1:5] OF CHAR
B G[1] ← 95
C OUTPUT G[1]
Line B — G is an array of CHAR, so every element must be a single character. The number 95 is the wrong data type. The line should be G[1] ← 'A'.

Student with a class code? Join your class →