Cambridge O Level Computer Science · Syllabus 2210 · Programming
Constant
What is Constant?
A named value fixed by a literal at the start of the program, which does not change while the program is running; it makes code clearer and easier to update.
This definition is part of the Programming chapter in Cambridge O Level Computer Science.
Constant in context
A program is a stored sequence of instructions that manipulates data held in named storage. Topic 8 asks you to do four things with that idea. First, name and type your data correctly: a variable whose value may change, a constant whose value may not, each with one of the five data types INTEGER, REAL, CHAR, STRING, BOOLEAN. Second, control the order in which instructions run using only three structures — sequence, selection (IF, CASE) and iteration (FOR, WHILE, REPEAT). Third, break a long solution into procedures and functions so it stays readable and testable. Fourth, hold many related values in an array and hold them beyond the end of the run in a file. Everything else in this chapter is detail hanging off those four moves.
A variable is a named storage location whose value may change while the program runs; it is created with DECLARE <identifier> : <data type>. A constant is a named value that does not change while the program runs; it is created with CONSTANT <identifier> ← <value>, and only a literal may be used as the value — never a variable, another constant or an expression. Both must have a meaningful identifier. Every variable also has a data type that fixes what kind of value it can hold and what operations are legal on it.
A maintainable program is one that another programmer — or you, six months later — can read, understand and safely change. The syllabus names the ingredients: meaningful identifiers for variables, constants, arrays, procedures and functions; relevant and appropriate use of the commenting feature provided by the language; and the use of procedures and functions to break the solution into named pieces. Consistent indentation and the removal of unnecessary repeated code follow from those. The syllabus lists it as a learning outcome of its own, 8.1.8, so it is something you can be asked about directly as well as something to practise in every answer you write.
Common mistakes with Constant
- M1. “A variable and a constant are basically the same — use whichever.” TruthA variable's value may change while the program runs; a constant's may not. They are also declared differently: DECLARE Counter : INTEGER against CONSTANT PassMark ← 50. TestIf the program ever assigns to it after the start, it must be a variable. If not, a constant is clearer and safer.
- M20. “Making everything global is good practice — it saves passing things around.” TruthIt makes writing quicker and debugging slower. Any routine can change a global, so when one holds the wrong value every routine is a suspect, and no routine can be tested on its own. BetterPass values in as parameters and hand results back with a function's return value. Use a constant for a fixed value that several routines need.
Examiner tips on Constant
- Version history you should know about, because old material contradicts it. Two things in the pseudocode specification changed during this syllabus cycle, and textbooks and worksheets printed before them are still in circulation. Integer division operators became function calls. Version 3 (January 2025) and version 4 (June 2025) both record that “the names of operators” were updated. The current specification writes DIV(<identifier1>, <identifier2>) and MOD(<identifier1>, <identifier2>), with the examples DIV(10, 3) returns 3 and MOD(10, 3) returns 1. The older infix forms 10 DIV 3 and 10 MOD 3 appear in a great deal of older material. This chapter uses the current function form throughout, and quotes the old form only to correct it. Parameter count was fixed at three. Version 4 records that “the number of parameters for a function and procedure has been updated”. Topic 8.1.6 now states that procedures and functions may have up to three parameters. Do not design an answer that needs four. Constants are declared with the arrow. The current specification gives the form CONSTANT <identifier> ← <value>, with the examples CONSTANT HourlyRate ← 6.50 and CONSTANT DefaultText ← "N/A". Some earlier material writes CONSTANT HourlyRate = 6.50. This chapter uses the arrow form, because it is what the current specification prints — so it is what you should train. Version 5 itself (December 2025) changed only a weblink on page 50. No Topic 8 content and no pseudocode convention changed between version 4 and version 5.
Questions students ask about Constant
What is the difference between a variable and a constant?
A variable is a named storage location, declared with DECLARE and a data type, whose value may change while the program is running. A constant is a named value fixed with CONSTANT and a literal at the start of the program, and it must never change while the program runs — only a literal may be used as its value, never a variable, another constant or an expression. If a program ever assigns to it after the start, it must be a variable; if not, a constant is clearer and safer.

