← IGCSE Computer Science Paper 2

Declaring a 1D array: DECLARE name : ARRAY[l:u] OF type

Declares a 1D array named StudentNames with indexes 1 to 30 (lower:upper), each element holding a STRING. It only sets up the array; no values are stored yet.

Understanding Declaring a 1D array: DECLARE name : ARRAY[l:u] OF type in IGCSE Computer Science Paper 2

What it does: [1:30] shows the lower bound 1, a colon, then the upper bound 30, all inside square brackets. The DECLARE line only creates the empty array. The second line is a separate assignment that stores the value 15 in element 1. A declaration does not store any values. You must assign values to the elements yourself before using them. The data type comes at the end, after the word OF: ARRAY[l:u] OF type. Cambridge pseudocode uses OF: ARRAY[1:30] OF STRING. AS is not part of this syntax. The numbers 1:7 are the lower and upper bounds (indexes 1 to 7), not stored values. The array has 7 elements, each able to hold a REAL.

Common mistakes: The array was declared with indexes 1 to 5, so index 6 is above the upper bound and is out of range. The line should be G[5] ← 'B'. The lower and upper bounds must be separated by a colon, not a comma. It should be ARRAY[1:7].

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 line correctly declares a 1D array of 30 student names (indexes 1 to 30)?
DECLARE StudentNames : ARRAY(1:30) OF STRINGDECLARE StudentNames : ARRAY[1:30] OF STRING
Matches
DECLARE Names : ARRAY(1:30) OF STRING
↓
Round brackets are used instead of square brackets. The bounds must be written as [1:30].
Applying
Meanings
Term
DECLARE StudentNames : ARRAY[1:30] OF STRING
Meaning
Declares a 1D array named StudentNames with indexes 1 to 30 (lower:upper), each element holding a STRING. It only sets up the array; no values are stored yet.
Practice
DECLARE StudentNames : ARRAY[1:30] OF STRING
Testing
Gaps
DECLARE StudentNames : ARRAY[1:30] OF
Check Answer
Spots
3G[2] ← 'C'
4G[6] ← 'B'

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

The 'Peregrine Falcon' badge — Operator Ace, 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 line correctly declares a 1D array of 30 student names (indexes 1 to 30)?
A. DECLARE StudentNames : ARRAY(1:30) OF STRING
B. DECLARE StudentNames : ARRAY[1:30] OF STRING ✓
Array bounds go in square brackets [ ], not round brackets. The form is ARRAY[lower:upper] OF type.
2. In ARRAY[1:30], what separates the lower bound from the upper bound?
A. A colon : ✓
B. A comma ,
The lower and upper bounds of a 1D array are separated by a colon, like [1:30]. A comma would be used to separate dimensions in a 2D array.
3. After running DECLARE Scores : ARRAY[1:5] OF INTEGER, what values are stored in the array?
A. None yet - the declaration only sets up the array ✓
B. Five zeros, one in each element
A declaration does not store any values. You must assign values to the elements yourself before using them.
4. Which declaration puts the data type in the correct place?
A. DECLARE Prices : REAL ARRAY[1:10] OF
B. DECLARE Prices : ARRAY[1:10] OF REAL ✓
The data type comes at the end, after the word OF: ARRAY[l:u] OF type.
5. For DECLARE StudentNames : ARRAY[1:30] OF STRING, what is the lower bound?
A. 1 ✓
B. 30
The number before the colon is the lower bound (1). The number after the colon is the upper bound (30).

Match the Pairs

DECLARE Marks : ARRAY[1:25] OF INTEGER → Declares a 1D array called Marks with indexes 1 to 25, so it has 25 elements, each holding an INTEGER
DECLARE Temps : ARRAY[0:6] OF REAL → Declares a 1D array called Temps with indexes 0 to 6, so it has 7 elements, each holding a REAL number
The bounds go inside square brackets with the lower bound first, then a colon, then the upper bound → DECLARE Names : ARRAY[1:30] OF STRING
The declaration only sets up the array and its data type; it does not store any values, so a separate assignment is needed to fill an element → DECLARE Scores : ARRAY[1:10] OF INTEGER Scores[1] ← 15
DECLARE Names : ARRAY(1:30) OF STRING → Round brackets are used instead of square brackets. The bounds must be written as [1:30].
DECLARE Marks : ARRAY[1:20] INTEGER → The word OF is missing before the data type. It should be ARRAY[1:20] OF INTEGER.

Key Term

DECLARE StudentNames : ARRAY[1:30] OF STRING
Declares a 1D array named StudentNames with indexes 1 to 30 (lower:upper), each element holding a STRING. It only sets up the array; no values are stored yet.

Fill in the Blanks

1. DECLARE StudentNames : ARRAY[1:30] OF STRING
Hint: Type the data type that each element holds, since student names are text.
2. DECLARE Scores : ARRAY[1:10] OF INTEGER
Hint: Type the keyword that starts a declaration statement.
3. DECLARE Marks : ARRAY[1:20] OF INTEGER
Hint: Type the symbol that separates the lower bound from the upper bound.
4. DECLARE Temperatures : ARRAY[0:6] OF REAL
Hint: Type the keyword that links the bounds to the data type.
5. // one element for each month DECLARE Rainfall : ARRAY[1:12] OF REAL
Hint: Type the upper bound that gives one element for each month, starting from lower bound 1.

Spot the Error

Question 1
A DECLARE G : ARRAY[1:5] OF CHAR
B G[1] ← 'A'
C G[2] ← 'C'
D G[6] ← 'B'
Line D — The array was declared with indexes 1 to 5, so index 6 is above the upper bound and is out of range. The line should be G[5] ← 'B'.
Question 2
A // T = 7 daily temperatures
B DECLARE T : ARRAY[1,7] OF REAL
C T[1] ← 21.5
D T[2] ← 19.0
Line B — The lower and upper bounds must be separated by a colon, not a comma. It should be ARRAY[1:7].
Question 3
A DECLARE L : ARRAY[1:3] OF CHAR
B L[1] ← 'x'
C L(2) ← 'y'
D L[3] ← 'z'
Line C — Array indexes use square brackets, not round brackets. The line should be L[2] ← 'y'.
Question 4
A DECLARE P : ARRAY[1:9] REAL
B P[1] ← 1.5
C P[2] ← 4.0
Line A — The word OF is missing between the bounds and the data type. It should be DECLARE P : ARRAY[1:9] OF REAL.
Question 5
A // F = 4 fruit initials
B DECLARE F : ARRAY[1:4] OF CHAR
C F[0] ← 'A'
D F[2] ← 'P'
Line C — The lower bound is 1, so index 0 does not exist in this array. The first element is F[1], so the line should be F[1] ← 'A'.

Student with a class code? Join your class →