← IGCSE Computer Science Paper 2

Lower bound and upper bound

In ARRAY[l:u], l is the lower bound (index of the first element) and u is the upper bound (index of the last). Here the lower bound is 1 and the upper bound is 30.

Understanding Lower bound and upper bound in IGCSE Computer Science Paper 2

What it does: In ARRAY[1:25] the 1 before the colon is the lower bound, so the first element is Marks[1]. The upper bound is the second number in l:u. It is the index of the last element, so here it is 30. The bounds are separated by a colon, written l:u. A hyphen is not used. The indexes are consecutive. They run from the lower bound to the upper bound with none missing: 1, 2, 3 ... 30.

Common mistakes: In ARRAY[1:30] the lower bound is the index of the first element, which is 1. It should be lower ← 1. The value 30 is the upper bound. The upper bound of ARRAY[1:7] is 7, so the last valid index is 7. Temp[8] is outside the bounds. It should be OUTPUT Temp[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
In ARRAY[1:30], what is the lower bound?
301
Matches
DECLARE Scores : ARRAY[30:1] OF INTEGER
↓
The bounds are written the wrong way round. The lower bound must come first and the upper bound second, as l:u, so it should be ARRAY[1:30].
Applying
Meanings
Term
ARRAY[1:30]
Meaning
In ARRAY[l:u], l is the lower bound (index of the first element) and u is the upper bound (index of the last). Here the lower bound is 1 and the upper bound is 30.
Practice
DECLARE Marks : ARRAY[1:30] OF INTEGER
Testing
Gaps
DECLARE Scores : ARRAY[:30] OF INTEGER
Check Answer
Spots
1// Bounds of ARRAY[1:30]
2lower ← 30

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

The 'Silverback Gorilla' badge — Savannah 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. In ARRAY[1:30], what is the lower bound?
A. 30
B. 1 ✓
The lower bound is the first number in l:u. It is the index of the first element, so here it is 1.
2. In ARRAY[1:30], what is the upper bound?
A. 30 ✓
B. 1
The upper bound is the second number in l:u. It is the index of the last element, so here it is 30.
3. Which shows the bounds written in the correct order?
A. ARRAY[30:1]
B. ARRAY[1:30] ✓
Bounds are always written l:u, lower bound first and then upper bound. The lower bound must not be bigger than the upper bound.
4. The lower bound of an array is...
A. the index of the first element ✓
B. the number of elements in the array
The lower bound is an index, not a count. It is the index of the first element.
5. Which is the correct way to separate the bounds in an array declaration?
A. ARRAY[1:30] ✓
B. ARRAY[1-30]
The bounds are separated by a colon, written l:u. A hyphen is not used.

Match the Pairs

ARRAY[1:30] → An array whose first element has index 1 (lower bound) and whose last element has index 30 (upper bound)
ARRAY[0:9] → The lower bound is 0 and the upper bound is 9, so the indexes run 0, 1, 2 ... 9
The lower bound is the index of the first element, written before the colon → DECLARE Marks : ARRAY[1:25] OF INTEGER
The upper bound is the index of the last element, written after the colon → DECLARE Names : ARRAY[1:40] OF STRING
DECLARE Scores : ARRAY[30:1] OF INTEGER → The bounds are written the wrong way round. The lower bound must come first and the upper bound second, as l:u, so it should be ARRAY[1:30].
DECLARE Ages : ARRAY[1,20] OF INTEGER → The two bounds are separated by a comma instead of a colon. A 1D array needs l:u, so it should be ARRAY[1:20].

Key Term

ARRAY[1:30]
In ARRAY[l:u], l is the lower bound (index of the first element) and u is the upper bound (index of the last). Here the lower bound is 1 and the upper bound is 30.

Fill in the Blanks

1. DECLARE Scores : ARRAY[1:30] OF INTEGER // 30 elements, first index is 1
Hint: Type the lower bound, the index of the first element.
2. DECLARE Names : ARRAY[1:30] OF STRING // the last element has index 30
Hint: Type the upper bound, the index of the last element.
3. DECLARE Temp : ARRAY[0:6] OF REAL // 7 elements, first index is zero
Hint: Type the lower bound for an array whose indexes start at zero.
4. DECLARE Marks : ARRAY[1:30] OF INTEGER
Hint: Type the symbol that separates the lower bound from the upper bound.
5. DECLARE Scores : ARRAY[1:30] OF INTEGER FOR Index ← 1 TO 30 NEXT Index
Hint: Type the upper bound so the loop visits every index up to the last element.

Spot the Error

Question 1
A // Bounds of ARRAY[1:30]
B lower ← 30
C upper ← 30
Line B — In ARRAY[1:30] the lower bound is the index of the first element, which is 1. It should be lower ← 1. The value 30 is the upper bound.
Question 2
A // Temp is ARRAY[1:7]
B Temp[1] ← 18
C Temp[7] ← 25
D OUTPUT Temp[8]
Line D — The upper bound of ARRAY[1:7] is 7, so the last valid index is 7. Temp[8] is outside the bounds. It should be OUTPUT Temp[7].
Question 3
A // Names is ARRAY[0:9]
B first ← 0
C last ← 10
Line C — In ARRAY[0:9] the upper bound is 9, which is the index of the last element. It should be last ← 9. Index 10 does not exist.
Question 4
A // Prices holds 12 values
B // Declared as ARRAY[12:1]
C OUTPUT Prices[1]
Line B — Bounds are written lower:upper, so the lower bound comes first. It should be ARRAY[1:12]. The lower bound cannot be larger than the upper bound.
Question 5
A // Pupils is ARRAY[1,30]
B FOR n ← 1 TO 30
C OUTPUT Pupils[n]
D NEXT n
Line A — The lower and upper bounds are separated by a colon, written l:u. It should be ARRAY[1:30]. A comma is used to separate the dimensions of a 2D array.

Student with a class code? Join your class →