← IGCSE Computer Science Paper 2

DECLARE a variable (7c)

Creates a variable named Counter and states its data type (INTEGER) before it is used. The format is DECLARE <identifier> : <data type>, with a space on each side of the colon.

Understanding DECLARE a variable (7c) in IGCSE Computer Science Paper 2

What it does: A price with pence needs a number with a decimal part, so the data type is REAL. The format is DECLARE <identifier> : <data type>. BOOLEAN is the data type for TRUE or FALSE values. STRING is for text. A variable must be declared before use, so the algorithm knows its name and data type. Write a space on each side of the colon: DECLARE Counter : INTEGER. Declare the variable first, then give it a value. Using it before declaring it is an error.

Common mistakes: The colon is missing. The format is DECLARE <identifier> : <data type>, so it should be DECLARE GameOver : BOOLEAN. Pseudocode keywords must be written in upper case. It should be DECLARE Counter : INTEGER.

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 146–155) and word search (Modules 146–165).

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 variable to count how many lives a player has left?
DECLARE Lives INTEGERDECLARE Lives : INTEGER
Matches
Counter ← 0 DECLARE Counter : INTEGER
↓
The variable is used before it is declared. The DECLARE line must come first, then the assignment.
Applying
Meanings
Term
DECLARE Counter : INTEGER
Meaning
Creates a variable named Counter and states its data type (INTEGER) before it is used. The format is DECLARE <identifier> : <data type>, with a space on each side of the colon.
Practice
DECLARE Counter : INTEGER
Testing
Gaps
Counter : INTEGER
Check Answer
Spots
2DECLARE TotalToPay : REAL
3DECLARE GameOver BOOLEAN

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

The 'Jellyfish' badge — Flow Controller, 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 variable to count how many lives a player has left?
A. DECLARE Lives INTEGER
B. DECLARE Lives : INTEGER ✓
A DECLARE statement needs a colon between the identifier and the data type: DECLARE <identifier> : <data type>.
2. Which line declares a variable to store a price that can include pence, such as 12.50?
A. DECLARE TotalToPay : INTEGER
B. DECLARE TotalToPay : REAL ✓
A price can have decimal places, so the data type is REAL. INTEGER only stores whole numbers.
3. Which line correctly declares a variable that holds TRUE or FALSE to show whether a game has ended?
A. DECLARE GameOver : BOOLEAN ✓
B. DECLARE GameOver : STRING
BOOLEAN is the data type for TRUE or FALSE values. STRING is for text.
4. When should DECLARE Counter : INTEGER appear in an algorithm?
A. Before Counter is used ✓
B. After Counter has been used
A variable must be declared before use, so the algorithm knows its name and data type.
5. Which line follows the standard layout for spacing around the colon?
A. DECLARE Counter : INTEGER ✓
B. DECLARE Counter:INTEGER
Write a space on each side of the colon: DECLARE Counter : INTEGER.

Match the Pairs

DECLARE Counter : INTEGER → Creates a variable called Counter that can only store whole numbers
DECLARE GameOver : BOOLEAN → Creates a variable called GameOver that can only hold TRUE or FALSE
Declare a variable to store a price that has decimal places → DECLARE TotalToPay : REAL
A variable must be declared before it is used, so DECLARE comes first → DECLARE Counter : INTEGER Counter ← 0
Counter ← 0 DECLARE Counter : INTEGER → The variable is used before it is declared. The DECLARE line must come first, then the assignment.
DECLARE TotalToPay REAL → The colon is missing. The correct format is DECLARE TotalToPay : REAL, with a space on each side of the colon.

Key Term

DECLARE Counter : INTEGER
Creates a variable named Counter and states its data type (INTEGER) before it is used. The format is DECLARE <identifier> : <data type>, with a space on each side of the colon.

Fill in the Blanks

1. DECLARE Counter : INTEGER
Hint: Type the keyword that creates a variable and states its data type.
2. DECLARE TotalToPay : REAL
Hint: Type the data type for a number with decimal places, such as a price.
3. DECLARE GameOver : BOOLEAN
Hint: Type the data type that can only hold TRUE or FALSE.
4. DECLARE Counter : INTEGER
Hint: Type the symbol that separates the identifier from its data type.
5. DECLARE Counter : INTEGER Counter ← 0
Hint: Type the identifier that was declared on the line above, so it can be used after being declared.

Spot the Error

Question 1
A DECLARE Counter : INTEGER
B DECLARE TotalToPay : REAL
C DECLARE GameOver BOOLEAN
Line C — The colon is missing. The format is DECLARE <identifier> : <data type>, so it should be DECLARE GameOver : BOOLEAN.
Question 2
A declare Counter : INTEGER
B Counter ← 0
C OUTPUT Counter
Line A — Pseudocode keywords must be written in upper case. It should be DECLARE Counter : INTEGER.
Question 3
A DECLARE Score : INTEGER
B DECLARE Price : REAL
C DECLARE Name : STRING
D DECLARE Done : BOOL
Line D — BOOL is not a pseudocode data type. The correct data type name is BOOLEAN, so the line should be DECLARE Done : BOOLEAN.
Question 4
A DECLARE Total : INTEGER
B DECLARE Count:INTEGER
C Total ← 0
D Count ← 0
Line B — There must be a space on each side of the colon. It should be DECLARE Count : INTEGER.
Question 5
A DECLARE Price : REAL
B DECLARE Qty : INTEGER
C Price ← 4.5
D Qty ← 2.5
Line D — Qty was declared as INTEGER, so it can only store whole numbers. 2.5 is a REAL value, so use a whole number such as Qty ← 2.

Student with a class code? Join your class →