← IGCSE Computer Science Paper 2

Array bounds starting at zero or one

The number before the colon is the lower bound, the first index. ARRAY[1:30] starts at 1, ARRAY[0:29] starts at 0. Both hold 30 elements, so always state the lower bound.

Understanding Array bounds starting at zero or one in IGCSE Computer Science Paper 2

What it does: The lower bound 1 is written in the declaration, so anyone reading it knows the first element is Names[1]. With ARRAY[0:29], the first element is at index 0, so Scores[0] outputs it. Count from lower to upper bound. 0 to 29 is 30 indexes and 1 to 30 is 30 indexes, so both hold 30 elements.

Common mistakes: The lower bound must come first, before the colon, and the upper bound after it. It should be ARRAY[1:5], which holds 5 elements. The bounds are 0 to 4, so index 5 is out of range. The first element is M[0], so the line should be M[0] ← 'A'.

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 449–458) 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
DECLARE Scores : ARRAY[0:29] OF INTEGER. What is the index of the first element?
10
Matches
DECLARE Marks : ARRAY[0:30] OF INTEGER // the student wants exactly 30 elements
↓
ARRAY[0:30] holds 31 elements (0 to 30). For 30 elements starting at 0, use ARRAY[0:29]. Or use ARRAY[1:30] to start at 1.
Applying
Meanings
Term
ARRAY[1:30]
Meaning
The number before the colon is the lower bound, the first index. ARRAY[1:30] starts at 1, ARRAY[0:29] starts at 0. Both hold 30 elements, so always state the lower bound.
Practice
DECLARE Names : ARRAY[1:30] OF STRING
Testing
Gaps
DECLARE Names : ARRAY[:30] OF STRING
Check Answer
Spots
1DECLARE S : ARRAY[5:1] OF REAL
2S[1] ← 7.5

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

The 'Ermine' badge — Tundra Streak, 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. DECLARE Scores : ARRAY[0:29] OF INTEGER. What is the index of the first element?
A. 0 ✓
B. 1
The number before the colon is the lower bound, so it is the first index. Here it is 0.
2. DECLARE Names : ARRAY[1:30] OF STRING. Which element is the first one?
A. Names[1] ✓
B. Names[0]
The lower bound is 1, so the first element is Names[1]. Names[0] would be out of range.
3. How many elements do ARRAY[0:29] and ARRAY[1:30] each hold?
A. ARRAY[0:29] holds 29 and ARRAY[1:30] holds 30
B. Both hold 30 elements ✓
Count from lower to upper bound. 0 to 29 is 30 indexes and 1 to 30 is 30 indexes, so both hold 30 elements.
4. Which is the better practice when declaring an array in pseudocode?
A. State the lower bound explicitly, such as ARRAY[1:30] ✓
B. Leave the lower bound out and let the computer assume it
The declaration should always state the lower bound so there is no doubt where the array starts.
5. Which lower bound does the Cambridge IGCSE syllabus generally use in its pseudocode?
A. 0
B. 1 ✓
The syllabus generally uses a lower bound of 1, but you must always read the declaration to check.

Match the Pairs

DECLARE Scores : ARRAY[0:29] OF INTEGER → The first index is 0 and the last is 29, so the array holds 30 elements
DECLARE Scores : ARRAY[1:30] OF INTEGER → The first index is 1 and the last is 30, so the array holds 30 elements
Stating the lower bound explicitly in the declaration shows whether the first element is at index 0 or 1 → DECLARE Names : ARRAY[1:20] OF STRING
In an array with lower bound 0, the first element is read using index 0 → OUTPUT Scores[0]
DECLARE Marks : ARRAY[0:30] OF INTEGER // the student wants exactly 30 elements → ARRAY[0:30] holds 31 elements (0 to 30). For 30 elements starting at 0, use ARRAY[0:29]. Or use ARRAY[1:30] to start at 1.
DECLARE Marks : ARRAY[0:29] OF INTEGER OUTPUT Marks[30] → Index 30 is out of range because the upper bound is 29. The last element is Marks[29], and the first is Marks[0].

Key Term

ARRAY[1:30]
The number before the colon is the lower bound, the first index. ARRAY[1:30] starts at 1, ARRAY[0:29] starts at 0. Both hold 30 elements, so always state the lower bound.

Fill in the Blanks

1. DECLARE Names : ARRAY[1:30] OF STRING
Hint: Type the lower bound the syllabus generally uses, so the first index is the smallest counting number.
2. DECLARE Scores : ARRAY[0:29] OF INTEGER
Hint: Type the upper bound that gives 30 elements when counting from a lower bound of zero.
3. DECLARE Marks : ARRAY[0:29] OF INTEGER OUTPUT Marks[0]
Hint: Type the index of the first element when the lower bound is zero.
4. DECLARE Marks : ARRAY[0:29] OF INTEGER FOR Index ← 0 TO 29 OUTPUT Marks[Index]
Hint: Type the starting value of the loop counter so it begins at the array's lower bound.
5. DECLARE Names : ARRAY[1:30] OF STRING OUTPUT Names[30]
Hint: Type the index of the last element in this array that starts counting at its lower bound of one.

Spot the Error

Question 1
A DECLARE S : ARRAY[5:1] OF REAL
B S[1] ← 7.5
C OUTPUT S[1]
Line A — The lower bound must come first, before the colon, and the upper bound after it. It should be ARRAY[1:5], which holds 5 elements.
Question 2
A DECLARE M : ARRAY[0:4] OF CHAR
B M[5] ← 'A'
C M[4] ← 'E'
D OUTPUT M[0]
Line B — The bounds are 0 to 4, so index 5 is out of range. The first element is M[0], so the line should be M[0] ← 'A'.
Question 3
A DECLARE P : ARRAY[9] OF CHAR
B FOR I ← 0 TO 9
C P[I] ← '*'
D NEXT I
Line A — The declaration must state both the lower and the upper bound, like [0:9]. Writing only one number does not say where the indexes start.
Question 4
A DECLARE T : ARRAY[1:9] OF CHAR
B FOR I ← 0 TO 9
C T[I] ← 'x'
D NEXT I
Line B — The lower bound is 1, so there is no T[0]. The loop would start at an index that does not exist. It should be FOR I ← 1 TO 9.
Question 5
A DECLARE W : ARRAY[1:3] OF CHAR
B W[1] ← 'a'
C W[0] ← 'c'
D OUTPUT W[1]
Line C — The lower bound is 1, so index 0 does not exist. The last element of ARRAY[1:3] is W[3], so the line should be W[3] ← 'c'.

Student with a class code? Join your class →