← IGCSE Computer Science Paper 2

Declaring a constant with CONSTANT

Declares a named value that is set once. No DECLARE line or data type is needed: the type comes from the literal, so 6.50 makes it REAL. The value cannot change later.

Understanding Declaring a constant with CONSTANT in IGCSE Computer Science Paper 2

What it does: This line follows the pattern CONSTANT <identifier> ← <value>, with the literal 100 as the value. There is only one line and no type is written. The literal 0.20 has a decimal point, so VATRate is a REAL. CONSTANT HourlyRate ← 6.50 is the complete declaration. No DECLARE line is needed. Cambridge pseudocode uses the ← operator to give a constant its value, not the = sign. A constant keeps the same value for the whole program. If a value needs to change, use a variable.

Common mistakes: A CONSTANT line has no data type. The type comes from the literal, so 6.50 makes it REAL. It should be CONSTANT Rate ← 6.50. A string literal must be in double quotes. Without them, N/A is not a valid value. It should be CONSTANT DefaultText ← "N/A".

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 317–326) and word search (Modules 317–336).

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 constant for an hourly pay rate?
CONSTANT HourlyRate ← 6.50DECLARE HourlyRate : CONSTANT
Matches
DECLARE HourlyRate : REAL CONSTANT HourlyRate ← 6.50
↓
A constant must not have a DECLARE line or a data type. Remove the DECLARE line and keep only CONSTANT HourlyRate ← 6.50.
Applying
Meanings
Term
CONSTANT HourlyRate ← 6.50
Meaning
Declares a named value that is set once. No DECLARE line or data type is needed: the type comes from the literal, so 6.50 makes it REAL. The value cannot change later.
Practice
CONSTANT HourlyRate ← 6.50
Testing
Gaps
HourlyRate ← 6.50
Check Answer
Spots
1CONSTANT Rate : REAL ← 6.50
2DECLARE Hours : INTEGER

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

The 'Moose' badge — Tundra Champion, 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 constant for an hourly pay rate?
A. DECLARE HourlyRate : CONSTANT
B. CONSTANT HourlyRate ← 6.50 ✓
A constant is declared with the CONSTANT keyword, an identifier, the ← operator and a literal value. DECLARE is only used for variables.
2. Does a constant need a DECLARE line before it?
A. Yes, DECLARE must come first
B. No, CONSTANT declares it on its own ✓
CONSTANT HourlyRate ← 6.50 is the complete declaration. No DECLARE line is needed.
3. What is the data type of CONSTANT HourlyRate ← 6.50 ?
A. REAL, because 6.50 is a decimal literal ✓
B. INTEGER, because it is a number
The type comes from the literal. A number with a decimal point is REAL, so the constant is REAL.
4. Which line gives the constant DefaultText the value N/A?
A. CONSTANT DefaultText ← "N/A" ✓
B. CONSTANT DefaultText : STRING ← "N/A"
You do not write a data type with CONSTANT. The double quotes around "N/A" make it a STRING literal, so the type is worked out from the value.
5. After CONSTANT HourlyRate ← 6.50, which statement is not allowed later in the program?
A. HourlyRate ← 7.00 ✓
B. OUTPUT HourlyRate
A constant is set once and cannot be changed. Reading it with OUTPUT is fine, but assigning a new value is not.

Match the Pairs

CONSTANT HourlyRate ← 6.50 → Declares a constant named HourlyRate with the value 6.50, so it is a REAL. The value is set once and cannot change.
CONSTANT DefaultText ← "N/A" → Declares a constant named DefaultText holding the string "N/A". No DECLARE line is needed because the text literal makes it a STRING.
A constant is declared with the CONSTANT keyword, an identifier, the ← operator and a literal value → CONSTANT MaxScore ← 100
A constant needs no DECLARE line and no data type, because the data type comes from the literal → CONSTANT VATRate ← 0.20
DECLARE HourlyRate : REAL CONSTANT HourlyRate ← 6.50 → A constant must not have a DECLARE line or a data type. Remove the DECLARE line and keep only CONSTANT HourlyRate ← 6.50.
CONSTANT DefaultText = "N/A" → A constant is given its value with the ← assignment arrow, not =. It should be CONSTANT DefaultText ← "N/A".

Key Term

CONSTANT HourlyRate ← 6.50
Declares a named value that is set once. No DECLARE line or data type is needed: the type comes from the literal, so 6.50 makes it REAL. The value cannot change later.

Fill in the Blanks

1. CONSTANT HourlyRate ← 6.50
Hint: Type the keyword that declares a named value which is set once.
2. CONSTANT HourlyRate ← 6.50
Hint: Type the symbol that gives the constant its value.
3. CONSTANT HourlyRate ← 6.50 OUTPUT HourlyRate * 8
Hint: Type the name of the constant declared on the line above.
4. CONSTANT HourlyRate ← 6.50 // Data type: REAL
Hint: Type the data type that comes from a literal with a decimal point.
5. CONSTANT DefaultText ← "N/A" // No DECLARE line is needed
Hint: Type the keyword used for variables that a constant does not need.

Spot the Error

Question 1
A CONSTANT Rate : REAL ← 6.50
B DECLARE Hours : INTEGER
C DECLARE Pay : REAL
D Hours ← 8
E Pay ← Rate * Hours
Line A — A CONSTANT line has no data type. The type comes from the literal, so 6.50 makes it REAL. It should be CONSTANT Rate ← 6.50.
Question 2
A DECLARE Name : STRING
B OUTPUT "Enter name"
C CONSTANT DefaultText ← N/A
D Name ← DefaultText
Line C — A string literal must be in double quotes. Without them, N/A is not a valid value. It should be CONSTANT DefaultText ← "N/A".
Question 3
A DECLARE Total : REAL
B CONSTANT HourlyRate = 6.50
C Total ← HourlyRate * 4
D OUTPUT Total
Line B — A constant is given its value with the ← operator, not =. It should be CONSTANT HourlyRate ← 6.50.
Question 4
A CONSTANT HourlyRate ← 6.50
B DECLARE Hours : INTEGER
C DECLARE MaxHours ← 40
D INPUT Hours
Line C — DECLARE is for variables and needs a data type. A constant uses the CONSTANT keyword. It should be CONSTANT MaxHours ← 40.
Question 5
A CONST DefaultText ← "N/A"
B DECLARE Reply : STRING
C Reply ← DefaultText
D OUTPUT Reply
Line A — The Cambridge pseudocode keyword is CONSTANT, not CONST. It should be CONSTANT DefaultText ← "N/A".

Student with a class code? Join your class →