← IGCSE Computer Science Paper 2

CONSTANT declarations

Names a fixed literal value that never changes while the program runs. It makes code easier to read, and you update the value in one place only.

Understanding CONSTANT declarations in IGCSE Computer Science Paper 2

What it does: 3.14 is a literal value, so it is allowed. A constant cannot be set from a calculation or from user INPUT. Changing 6.50 to 7.00 on this one line updates every place in the program that uses HourlyRate. This is what makes it a constant. Variables are the named values that can change. MaxScore tells the reader what 100 means. If the maximum changes, you edit this one line only. It should be CONSTANT HourlyRate ← 6.50. Do any calculation later, in a separate statement.

Common mistakes: Pay is hours worked multiplied by the hourly rate. The line should use * (OUTPUT Hours * HourlyRate), not +. A constant cannot be changed once it is declared. Assigning a new value to MaxScore is wrong. The line should only use MaxScore, for example in an OUTPUT.

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 27–36) and word search (Modules 27–46).

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 in Cambridge pseudocode?
CONSTANT HourlyRate ← 6.50DECLARE HourlyRate : CONSTANT 6.50
Matches
CONSTANT HourlyRate ← Hours * 6.50
↓
The value is a calculation using a variable, not a literal. A constant can only be given a literal value.
Applying
Meanings
Term
CONSTANT HourlyRate ← 6.50
Meaning
Names a fixed literal value that never changes while the program runs. It makes code easier to read, and you update the value in one place only.
Practice
CONSTANT HourlyRate ← 6.50
Testing
Gaps
HourlyRate ← 6.50
Check Answer
Spots
3INPUT Hours
4OUTPUT Hours + HourlyRate

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

The 'Kraken' badge — Deep Sea Master, 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 in Cambridge pseudocode?
A. DECLARE HourlyRate : CONSTANT 6.50
B. CONSTANT HourlyRate ← 6.50 ✓
A constant is declared with the keyword CONSTANT, then an identifier, then ← and a literal value.
2. A shop's VAT rate is 20% and never changes while the program runs. What should you use to store it?
A. CONSTANT VatRate ← 0.2 ✓
B. INPUT VatRate
A value that stays fixed while the program runs is a constant. INPUT is for values that change each time the program runs.
3. What can be on the right-hand side of ← in a CONSTANT declaration?
A. A calculation using another variable
B. A literal value such as 6.50 ✓
Only a literal can be the value of a constant. It cannot be a variable or the result of a calculation.
4. Which statement is true about a constant?
A. Its value does not change while the program runs. ✓
B. Its value changes each time it is used in a calculation.
This is what makes it a constant. Variables are the named values that can change.
5. The hourly rate of 6.50 is used on 20 different lines. The rate changes to 7.00. Using CONSTANT HourlyRate ← 6.50, what do you need to do?
A. Change the value on the one CONSTANT line ✓
B. Change the value on all 20 lines that use it
Changing the value in one place is a key benefit of a constant. Every line that uses HourlyRate gets the new value.

Match the Pairs

CONSTANT HourlyRate ← 6.50 → Declares a constant called HourlyRate that always holds the literal value 6.50
CONSTANT MaxScore ← 100 → Gives the fixed value 100 a meaningful name so the code is easier to read
A constant's value can only be a literal, such as a number, text or TRUE/FALSE → CONSTANT Pi ← 3.14
To change a constant's value, you edit it in one place only, where it is declared → CONSTANT HourlyRate ← 7.00
CONSTANT HourlyRate ← Hours * 6.50 → The value is a calculation using a variable, not a literal. A constant can only be given a literal value.
CONSTANT HourlyRate 6.50 → The assignment arrow ← is missing between the identifier and the value.

Key Term

CONSTANT HourlyRate ← 6.50
Names a fixed literal value that never changes while the program runs. It makes code easier to read, and you update the value in one place only.

Fill in the Blanks

1. CONSTANT HourlyRate ← 6.50
Hint: Type the keyword that declares a fixed value which never changes.
2. CONSTANT HourlyRate ← 6.50
Hint: Type the assignment symbol that gives the constant its value.
3. CONSTANT HourlyRate ← 6.50 Pay ← Hours * HourlyRate
Hint: Type the constant's name so the calculation uses it instead of a typed number.
4. // The pay rate rises to 7.00 CONSTANT HourlyRate ← 7.00
Hint: Type the new literal value, which is the only place that needs changing.
5. // A class has 30 students CONSTANT ClassSize ← 30
Hint: Type the literal value the constant is given, as described in the comment.

Spot the Error

Question 1
A CONSTANT HourlyRate ← 6.50
B DECLARE Hours : INTEGER
C INPUT Hours
D OUTPUT Hours + HourlyRate
Line D — Pay is hours worked multiplied by the hourly rate. The line should use * (OUTPUT Hours * HourlyRate), not +.
Question 2
A CONSTANT MaxScore ← 50
B DECLARE Score : INTEGER
C INPUT Score
D MaxScore ← Score
Line D — A constant cannot be changed once it is declared. Assigning a new value to MaxScore is wrong. The line should only use MaxScore, for example in an OUTPUT.
Question 3
A DECLARE Total : REAL
B CONSTANT VatRate ← 0.1 + 0.1
C INPUT Total
D OUTPUT Total * VatRate
Line B — A constant must be given a single literal value, not a calculation. It should be CONSTANT VatRate ← 0.2.
Question 4
A CONSTANT Pi ← 3.14
B DECLARE Radius : REAL
C INPUT Pi
D OUTPUT Pi * Radius ^ 2
Line C — A constant's value is fixed in its declaration, so the user cannot INPUT a new one. The line should be INPUT Radius, the variable.
Question 5
A DECLARE Count : INTEGER
B CONSTANT MaxItems = 10
C Count ← 0
D WHILE Count < MaxItems DO
E Count ← Count + 1
F ENDWHILE
Line B — A constant is declared with the assignment arrow ←, not =. It should be CONSTANT MaxItems ← 10.

Student with a class code? Join your class →