← IGCSE Computer Science Paper 2

Declaring a 1D array

Creates a fixed-length array. Its 30 elements are numbered from lower bound 1 to upper bound 30, and every element holds the same data type, here STRING.

Understanding Declaring a 1D array in IGCSE Computer Science Paper 2

What it does: [1:10] gives the lower bound 1 and upper bound 10 using a colon, which is the required form of the bounds. OF STRING sets the data type for all 20 elements, so none of them can hold a different type. The elements are numbered 1 to 30, so there are 30 of them. The keyword OF must come between the brackets and the data type. Pseudocode keywords such as DECLARE, ARRAY, OF and STRING are written in upper case. The lower bound is stated as 1, so numbering starts at 1. Element 0 does not exist in this array. The bounds 1:30 give 30 elements numbered 1 to 30, and OF STRING means every element holds a string.

Common mistakes: The array is declared with bounds 1:7, so the upper bound is 7. Index 8 does not exist. It should be an index from 1 to 7, such as T[3] ← 19.5. The bounds of an array must be written in square brackets, not round brackets. 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 176–187) and word search (Modules 166–187).

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 an array to store 30 student names, numbered from 1?
DECLARE StudentNames : ARRAY[1:30] OF STRINGDECLARE StudentNames : ARRAY[1,30] OF STRING
Matches
DECLARE StudentNames : ARRAY[1,30] OF STRING
↓
A comma is used between the bounds. It must be a colon, so write [1:30].
Applying
Meanings
Term
DECLARE StudentNames : ARRAY[1:30] OF STRING
Meaning
Creates a fixed-length array. Its 30 elements are numbered from lower bound 1 to upper bound 30, and every element holds the same data type, here STRING.
Practice
DECLARE StudentNames : ARRAY[1:30] OF STRING
Testing
Gaps
StudentNames : ARRAY[1:30] OF STRING
Check Answer
Spots
3T[2] ← 21.0
4T[8] ← 19.5

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

The 'Woolly Mammoth' badge — Tundra Master, 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 an array to store 30 student names, numbered from 1?
A. DECLARE StudentNames : ARRAY[1:30] OF STRING ✓
B. DECLARE StudentNames : ARRAY[1,30] OF STRING
The lower and upper bounds are separated by a colon, written ARRAY[1:30]. A comma is not used.
2. In DECLARE Scores : ARRAY[1:10] OF INTEGER, what is the lower bound?
A. 10
B. 1 ✓
The lower bound is the first number inside the brackets, so it is 1. The upper bound is 10.
3. How many elements does ARRAY[1:30] hold?
A. 30 ✓
B. 29
The elements are numbered 1 to 30, so there are 30 of them.
4. Which statement about the data type in an array declaration is true?
A. Every element has the same data type ✓
B. Each element can have a different data type
An array stores elements of one data type only. ARRAY[1:30] OF STRING means all 30 elements are STRING.
5. Which declaration is written correctly for an array of 5 whole-number marks?
A. DECLARE Marks : ARRAY[1:5] INTEGER
B. DECLARE Marks : ARRAY[1:5] OF INTEGER ✓
The keyword OF must come between the brackets and the data type.

Match the Pairs

DECLARE StudentNames : ARRAY[1:30] OF STRING → Creates an array of 30 STRING elements, numbered from 1 to 30
DECLARE Marks : ARRAY[1:25] OF INTEGER → Creates an array of 25 INTEGER elements, numbered from 1 to 25
An array declaration must state the lower bound and upper bound inside square brackets, separated by a colon → DECLARE Scores : ARRAY[1:10] OF INTEGER
Every element in an array has the same data type, which is stated after OF → DECLARE Names : ARRAY[1:20] OF STRING
DECLARE StudentNames : ARRAY[1,30] OF STRING → A comma is used between the bounds. It must be a colon, so write [1:30].
DECLARE StudentNames : ARRAY[1:30] → The data type is missing. OF STRING must be added after the bounds.

Key Term

DECLARE StudentNames : ARRAY[1:30] OF STRING
Creates a fixed-length array. Its 30 elements are numbered from lower bound 1 to upper bound 30, and every element holds the same data type, here STRING.

Fill in the Blanks

1. DECLARE StudentNames : ARRAY[1:30] OF STRING
Hint: Type the keyword that starts every variable or array declaration.
2. DECLARE StudentNames : ARRAY[1:30] OF STRING
Hint: Type the keyword that tells the computer this is a fixed-length list of elements.
3. DECLARE StudentNames : ARRAY[1:30] OF STRING
Hint: Type the lower bound, the number of the first element.
4. DECLARE StudentNames : ARRAY[1:30] OF STRING
Hint: Type the keyword that links the bounds to the data type of the elements.
5. // 30 whole-number marks DECLARE Marks : ARRAY[1:30] OF INTEGER
Hint: Type the data type that every element must hold, based on the comment.

Spot the Error

Question 1
A DECLARE T : ARRAY[1:7] OF REAL
B T[1] ← 18.5
C T[2] ← 21.0
D T[8] ← 19.5
Line D — The array is declared with bounds 1:7, so the upper bound is 7. Index 8 does not exist. It should be an index from 1 to 7, such as T[3] ← 19.5.
Question 2
A // Seven daily temperatures
B DECLARE T : ARRAY(1:7) OF REAL
C T[1] ← 18.5
Line B — The bounds of an array must be written in square brackets, not round brackets. It should be ARRAY[1:7].
Question 3
A DECLARE G : ARRAY[1:5] OF CHAR
B G[1] ← 'A'
C G[2] ← 7
D OUTPUT G[2]
Line C — Every element of an array holds the same data type. G is an array of CHAR, so it cannot store the number 7. It should be G[2] ← 'B'.
Question 4
A DECLARE T : ARRAY[1:7] OF REAL
B FOR I ← 0 TO 7
C INPUT T[I]
D NEXT I
Line B — The lower bound is 1, so the first element is T[1]. Starting the loop at 0 would use T[0], which does not exist. It should be FOR I ← 1 TO 7.
Question 5
A DECLARE G : ARRAY[1:5] OF CHAR
B G(1) ← 'A'
C OUTPUT G[1]
Line B — An element is chosen using square brackets around its index. G(1) uses round brackets. It should be G[1] ← 'A'.

Student with a class code? Join your class →