← IGCSE Computer Science Paper 2

Declaring a variable with DECLARE (8.1a)

Creates a variable called Counter that can only hold whole numbers. Use DECLARE name : TYPE, with a space either side of the colon, before you use the variable.

Understanding Declaring a variable with DECLARE (8.1a) in IGCSE Computer Science Paper 2

What it does: The pattern DECLARE identifier : data type creates a variable, here one that holds whole numbers. A value with a decimal part needs REAL. INTEGER can only hold whole numbers. BOOLEAN is the data type for TRUE and FALSE values. STRING is for text. Cambridge style puts a space either side of the colon: DECLARE name : TYPE. A variable must be declared before it is used. Assigning to Counter before the DECLARE is an error.

Common mistakes: BOOL is not a Cambridge pseudocode data type. The type must be written in full as BOOLEAN: DECLARE GameOver : BOOLEAN. The colon is missing between the identifier and the data type. It should be DECLARE TotalToPay : REAL.

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 307–316) and word search (Modules 296–316).

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 whole-number variable called Counter?
DECLARE Counter = INTEGERDECLARE Counter : INTEGER
Matches
DECLARE Counter INTEGER
↓
The colon is missing between the identifier and the data type. It should be DECLARE Counter : INTEGER
Applying
Meanings
Term
DECLARE Counter : INTEGER
Meaning
Creates a variable called Counter that can only hold whole numbers. Use DECLARE name : TYPE, with a space either side of the colon, before you use the variable.
Practice
DECLARE Counter : INTEGER
Testing
Gaps
Counter : INTEGER
Check Answer
Spots
3Counter ← 0
4DECLARE GameOver : BOOL

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 whole-number variable called Counter?
A. DECLARE Counter : INTEGER ✓
B. DECLARE Counter = INTEGER
A declaration uses a colon between the identifier and the data type, not an equals sign. Equals is not used in DECLARE.
2. Which line declares a variable to store a price that can have pence, such as 12.75?
A. DECLARE TotalToPay : INTEGER
B. DECLARE TotalToPay : REAL ✓
A value with a decimal part needs REAL. INTEGER can only hold whole numbers.
3. Which line declares a variable that stores TRUE or FALSE?
A. DECLARE GameOver : STRING
B. DECLARE GameOver : BOOLEAN ✓
BOOLEAN is the data type for TRUE and FALSE values. STRING is for text.
4. Which is the correct layout of a DECLARE statement in Cambridge pseudocode?
A. DECLARE Counter : INTEGER ✓
B. DECLARE Counter: INTEGER
Cambridge style puts a space either side of the colon: DECLARE name : TYPE.
5. Which program declares the variable at the correct time?
A. DECLARE Counter : INTEGER Counter ← 0 ✓
B. Counter ← 0 DECLARE Counter : INTEGER
A variable must be declared before it is used. Assigning to Counter before the DECLARE is an error.

Match the Pairs

DECLARE TotalToPay : REAL → Creates a variable called TotalToPay that can hold numbers with decimal places, such as a price
DECLARE GameOver : BOOLEAN → Creates a variable called GameOver that can only hold TRUE or FALSE
To create a variable that stores whole numbers, write DECLARE, then the name, a colon and the data type INTEGER → DECLARE Counter : INTEGER
A variable must be declared before it is used, so DECLARE comes on the line before the first assignment → DECLARE Score : INTEGER Score ← 0
DECLARE Counter INTEGER → The colon is missing between the identifier and the data type. It should be DECLARE Counter : INTEGER
Total ← 0 DECLARE Total : INTEGER → The variable is used before it is declared. The DECLARE line must come before the assignment

Key Term

DECLARE Counter : INTEGER
Creates a variable called Counter that can only hold whole numbers. Use DECLARE name : TYPE, with a space either side of the colon, before you use the variable.

Fill in the Blanks

1. DECLARE Counter : INTEGER
Hint: Type the keyword that creates a new variable before it is used.
2. DECLARE TotalToPay : REAL
Hint: Type the data type for a money total that can have decimal places.
3. DECLARE GameOver : BOOLEAN
Hint: Type the symbol that separates the variable name from its data type.
4. DECLARE Counter : INTEGER Counter ← 5
Hint: Type the data type that holds whole numbers only.
5. DECLARE Lives : INTEGER Lives ← 3 OUTPUT Lives
Hint: Type the variable name that was declared on the line above.

Spot the Error

Question 1
A // Game setup
B DECLARE Counter : INTEGER
C Counter ← 0
D DECLARE GameOver : BOOL
Line D — BOOL is not a Cambridge pseudocode data type. The type must be written in full as BOOLEAN: DECLARE GameOver : BOOLEAN.
Question 2
A DECLARE Counter : INTEGER
B Counter ← 0
C DECLARE TotalToPay REAL
D TotalToPay ← 9.99
Line C — The colon is missing between the identifier and the data type. It should be DECLARE TotalToPay : REAL.
Question 3
A DECLARE Score : INTEGER
B DECLARE Price: REAL
C Score ← 10
Line B — There must be a space on both sides of the colon. The line should be DECLARE Price : REAL.
Question 4
A DECLARE Lives : INTEGER
B DECLARE BOOLEAN : GameOver
C Lives ← 3
D GameOver ← FALSE
Line B — The identifier and the data type are the wrong way round. The name comes first, then the colon, then the type: DECLARE GameOver : BOOLEAN.
Question 5
A DECLARE Age : INTEGER
B DECLARE Height : REAL
C DEFINE Name : STRING
D Age ← 15
Line C — DEFINE is not a pseudocode keyword. A variable is created with the keyword DECLARE: DECLARE Name : STRING.

Student with a class code? Join your class →