Why use constants in a program
A named value used instead of a magic number. It makes code easier to read, and when the value changes you edit it in one place only, so no missed edits cause mistakes.
Understanding Why use constants in a program in IGCSE Computer Science Paper 2
What it does: The bare 0.2 is a magic number. Replacing it with a named constant such as VatRate would make the meaning clear. If the rate rises from 0.2 to 0.25, only this one line is edited. All lines that use VatRate then use the new value automatically. Constants make code more readable and easier to maintain. Their value is fixed while the program runs, so they are not changed by INPUT. The data type stays REAL. Using a named constant improves readability and makes updating simpler. Fix: declare CONSTANT VatRate ← 0.2 once and use VatRate on each line, so one edit updates them all.
Common mistakes: A constant is given its value with the ← operator, not =. It should be CONSTANT VatRate ← 0.2, so the named value is set in one place. 40 is a magic number here. The check should use the constant PassMark, so if the pass mark changes it only needs editing on line 1.
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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
CONSTANT VatRate ← 0.2Fill in the Blanks
Spot the Error
Student with a class code? Join your class →