← IGCSE Computer Science Paper 2

DECLARE and data types

Creates a variable called Score with a stated data type. Types: INTEGER, REAL, STRING, CHAR, BOOLEAN. Pick a meaningful name.

Understanding DECLARE and data types in IGCSE Computer Science Paper 2

What it does: REAL is the data type for numbers that can have decimal places, so it fits a price like 4.99. BOOLEAN variables hold only TRUE or FALSE, so they work well as flags like Found in a linear search. A name is made of several characters, so it is a STRING. CHAR holds just one single character. The form is DECLARE name : TYPE. The identifier comes first, then a colon, then the data type. A meaningful identifier such as LivesLeft shows what the variable stores, which makes the algorithm easier to read and check.

Common mistakes: The colon is missing. A declaration must be written DECLARE Name : STRING, with a colon between the identifier and the data type. Height is declared as REAL, so it must hold a number. Quotes make 1.65 a STRING. It should be Height ← 1.65.

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 254–264) and word search (Modules 254–274).

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 store a student's age in whole years?
DECLARE Age : INTEGERDECLARE Age : REAL
Matches
DECLARE Name STRING
↓
The colon is missing between the identifier and the data type. It should be DECLARE Name : STRING.
Applying
Meanings
Term
DECLARE Score : INTEGER
Meaning
Creates a variable called Score with a stated data type. Types: INTEGER, REAL, STRING, CHAR, BOOLEAN. Pick a meaningful name.
Practice
DECLARE Score : INTEGER
Testing
Gaps
DECLARE Score :
Check Answer
Spots
1DECLARE Score : INTEGER
2DECLARE Name STRING

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

The 'Bear' badge — Forest Guardian, 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 store a student's age in whole years?
A. DECLARE Age : REAL
B. DECLARE Age : INTEGER ✓
Whole numbers with no decimal part are stored as INTEGER. REAL is for numbers that can have a decimal part.
2. Which line correctly declares a variable to store a price such as 4.99?
A. DECLARE Price : REAL ✓
B. DECLARE Price : INTEGER
A price can have a decimal part, so it needs the REAL data type. INTEGER only holds whole numbers.
3. Which line correctly declares a variable to hold a player's name such as "Sam"?
A. DECLARE PlayerName : STRING ✓
B. DECLARE PlayerName : CHAR
A name is made of several characters, so it is a STRING. CHAR holds just one single character.
4. Which line correctly declares a variable to hold a single grade letter such as 'B'?
A. DECLARE Grade : CHAR ✓
B. DECLARE Grade : STRING
CHAR is the data type for exactly one character. STRING would be used for text with several characters.
5. Which line correctly declares a variable that stores either TRUE or FALSE?
A. DECLARE IsPassed : INTEGER
B. DECLARE IsPassed : BOOLEAN ✓
BOOLEAN is the data type for TRUE or FALSE values. INTEGER would hold whole numbers.

Match the Pairs

DECLARE Score : INTEGER → Creates a variable called Score that stores whole numbers only
DECLARE Grade : CHAR → Creates a variable called Grade that stores a single character such as 'A'
A variable that stores a number with a decimal part, such as a price → DECLARE Price : REAL
A variable that stores only TRUE or FALSE, such as whether a number was found → DECLARE Found : BOOLEAN
DECLARE Name STRING → The colon is missing between the identifier and the data type. It should be DECLARE Name : STRING.
DECLARE x : INTEGER → The identifier x is not meaningful, so it does not show what the variable stores. A name like Age or Score is better, for example DECLARE Age : INTEGER.

Key Term

DECLARE Score : INTEGER
Creates a variable called Score with a stated data type. Types: INTEGER, REAL, STRING, CHAR, BOOLEAN. Pick a meaningful name.

Fill in the Blanks

1. DECLARE Score : INTEGER Score ← 25
Hint: Type the data type used for whole numbers.
2. DECLARE Price : REAL Price ← 4.5
Hint: Type the keyword that creates a variable with a stated type.
3. DECLARE Initial : CHAR Initial ← 'A'
Hint: Type the data type that holds a single character.
4. DECLARE IsPassed : BOOLEAN IsPassed ← TRUE
Hint: Type the data type that holds only TRUE or FALSE.
5. DECLARE Height : REAL Height ← 1.75
Hint: Type the variable name that is used on the next line.

Spot the Error

Question 1
A DECLARE Score : INTEGER
B DECLARE Name STRING
C Score ← 0
D Name ← "Ava"
Line B — The colon is missing. A declaration must be written DECLARE Name : STRING, with a colon between the identifier and the data type.
Question 2
A DECLARE Age : INTEGER
B DECLARE Height : REAL
C Height ← "1.65"
D Age ← 15
Line C — Height is declared as REAL, so it must hold a number. Quotes make 1.65 a STRING. It should be Height ← 1.65.
Question 3
A DECLARE Grade : CHAR
B DECLARE Passed : BOOLEAN
C Grade ← 'BA'
D Passed ← TRUE
Line C — A CHAR holds exactly one character. 'BA' has two characters, so it should be Grade ← 'B'. Use STRING for longer text.
Question 4
A DECLARE Lives : NUMBER
B Lives ← 3
C OUTPUT Lives
Line A — NUMBER is not a Cambridge data type. A whole number such as Lives must be declared as INTEGER, or as REAL if it has decimals.
Question 5
A DECLARE IsOpen : BOOLEAN
B DECLARE Count : INTEGER
C Count ← 0
D IsOpen ← "TRUE"
Line D — A BOOLEAN can only hold TRUE or FALSE, written without quotes. With quotes it becomes a STRING. It should be IsOpen ← TRUE.

Student with a class code? Join your class →