← IGCSE Computer Science Paper 2

Declaring a variable with DECLARE (8.1b)

Names a variable (Count) and gives its data type (INTEGER) before use. Other types: REAL, STRING, BOOLEAN. Identifiers are capitalised with no spaces.

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

What it does: REAL is the data type for numbers with decimal places, so Price is declared as REAL. DECLARE Name : TYPE sets up the variable. It names it and says what type of data it can store. Identifiers cannot contain spaces. Capitalised words joined together, such as TotalScore, are the convention. A name is text, so the type is STRING. BOOLEAN only stores TRUE or FALSE. A colon separates the name from the type. The <- arrow is for assigning a value, not for giving a type.

Common mistakes: The colon between the identifier and the data type is missing. It should be DECLARE Price : REAL. Age was declared as INTEGER, so it cannot store text. It should be Age <- 15.

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 347–357) and word search (Modules 337–357).

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 Count?
DECLARE Count : INTEGERDECLARE Count : STRING
Matches
DECLARE Total Price : REAL
↓
The identifier contains a space. Identifiers must be one word with no spaces, e.g. TotalPrice.
Applying
Meanings
Term
DECLARE Count : INTEGER
Meaning
Names a variable (Count) and gives its data type (INTEGER) before use. Other types: REAL, STRING, BOOLEAN. Identifiers are capitalised with no spaces.
Practice
DECLARE Count : INTEGER
Testing
Gaps
Count : INTEGER
Check Answer
Spots
1DECLARE Total : INTEGER
2DECLARE Price REAL

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

The 'Stag' badge — Forest Legend, 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 Count?
A. DECLARE Count : STRING
B. DECLARE Count : INTEGER ✓
INTEGER is the data type for whole numbers. DECLARE names the variable and gives its type before it is used.
2. Which line correctly declares a variable to store a price such as 4.50?
A. DECLARE Price : REAL ✓
B. DECLARE Price : INTEGER
Prices can have decimal places, so the type is REAL. INTEGER only holds whole numbers.
3. True or false: DECLARE gives a variable its name and data type before the variable is used.
A. True ✓
B. False
DECLARE Name : TYPE sets up the variable. It names it and says what type of data it can store.
4. Which identifier is written correctly in Cambridge pseudocode?
A. DECLARE Total Score : INTEGER
B. DECLARE TotalScore : INTEGER ✓
Identifiers cannot contain spaces. Capitalised words joined together, such as TotalScore, are the convention.
5. Which declaration is the correct one for a variable that stores a person's name?
A. DECLARE Name : STRING ✓
B. DECLARE Name : BOOLEAN
A name is text, so the type is STRING. BOOLEAN only stores TRUE or FALSE.

Match the Pairs

DECLARE Count : INTEGER → Creates a variable called Count that can only store whole numbers
DECLARE Found : BOOLEAN → Creates a variable called Found that can only store TRUE or FALSE
Declare a variable to store a price with a decimal point, such as 4.99 → DECLARE Price : REAL
Declare a variable to store text such as a person's name → DECLARE Name : STRING
DECLARE Total Price : REAL → The identifier contains a space. Identifiers must be one word with no spaces, e.g. TotalPrice.
DECLARE Count INTEGER → The colon is missing between the identifier and the data type. It should be DECLARE Count : INTEGER.

Key Term

DECLARE Count : INTEGER
Names a variable (Count) and gives its data type (INTEGER) before use. Other types: REAL, STRING, BOOLEAN. Identifiers are capitalised with no spaces.

Fill in the Blanks

1. DECLARE Count : INTEGER
Hint: Type the keyword that starts a variable declaration.
2. DECLARE Price : REAL
Hint: Type the data type used for numbers with decimal places.
3. DECLARE Name : STRING
Hint: Type the data type used for text.
4. DECLARE Found : BOOLEAN
Hint: Type the data type that can only hold TRUE or FALSE.
5. DECLARE Total : INTEGER Total <- 0
Hint: Type the variable name being declared, matching the name used in the assignment on the next line.

Spot the Error

Question 1
A DECLARE Total : INTEGER
B DECLARE Price REAL
C Price <- 4.5
D Total <- 3
E OUTPUT Total * Price
Line B — The colon between the identifier and the data type is missing. It should be DECLARE Price : REAL.
Question 2
A DECLARE Name : STRING
B DECLARE Age : INTEGER
C Name <- "Sam"
D Age <- "fifteen"
Line D — Age was declared as INTEGER, so it cannot store text. It should be Age <- 15.
Question 3
A DECLARE Count : INTEGER
B DECLARE Found : BOOLEAN
C Count <- 0
D Found <- 0
Line D — Found was declared as BOOLEAN, so it can only hold TRUE or FALSE, not a number. It should be Found <- FALSE.
Question 4
A DECLARE Count : INTEGER
B DECLARE Price : REAL
C DECLARE Total Cost : REAL
D TotalCost <- Count * Price
Line C — An identifier cannot contain a space. It should be DECLARE TotalCost : REAL.
Question 5
A DECLARE Total : INTEGER
B DECLARE Count : INTEGER
C DECLARE Average : INTEGER
D Average <- Total / Count
Line C — An average can have decimal places, so Average should be declared as REAL, not INTEGER. It should be DECLARE Average : REAL.

Student with a class code? Join your class →