| Syllabus Item | What the note covers | AO Requirement |
|---|---|---|
| 11.1 Programming Basics – Constants | Definition, syntax, scope, naming, type‑checking, examples, and use in data structures. | AO1 – knowledge of constant declaration and initialisation. |
| 11.2 Programming Constructs (IF, CASE, loops, procedures) | Shows constants used inside IF, CASE, FOR/WHILE and procedures. | AO3 – design and implementation of algorithms using constants. |
| Testing & Evaluation (AO3) | Mentions constants in test data, expected results and documentation. | AO3 – planning and evaluating programs. |
| Ethics & Ownership (AO3) | Explains how constants reduce “magic numbers” and support maintainable, auditable code. | AO3 – ethical considerations in software development. |
MAX_STUDENTS) makes the purpose of a value obvious.| Concept | Cambridge Definition |
|---|---|
| Constant | A named value that, once initialised, cannot be changed during program execution. |
| Identifier | The name of a constant. Must start with a letter, may contain letters, digits and underscores, and is case‑sensitive. |
| Initialisation | Assigning a value to a constant at the moment of declaration. |
| Scope | Where the constant is visible. In Cambridge pseudocode a constant declared at the top of a program has global scope; a constant declared inside a procedure has local scope to that procedure. |
| Type‑checking | If a type is supplied, the initial value must be compatible (e.g., an INTEGER constant cannot be given a string value). |
If a type is specified, the value must match that type. If no type is given, the constant is typeless but must still be used consistently throughout the algorithm.
Use the CONST keyword, followed by the identifier, an optional type, the assignment arrow ←, and the value.
CONST identifier [: type] ← value
| Constant Name | Type (optional) | Value | Pseudocode Statement |
|---|---|---|---|
| MAX_STUDENTS | INTEGER | 30 | CONST MAX_STUDENTS : INTEGER ← 30 |
| PI | REAL | 3.14159 | CONST PI : REAL ← 3.14159 |
| WELCOME_MSG | STRING | "Welcome to the system" | CONST WELCOME_MSG : STRING ← "Welcome to the system" |
| GRAVITY | REAL | 9.81 | CONST GRAVITY : REAL ← 9.81 |
| DAYSINWEEK | INTEGER | 7 | CONST DAYSINWEEK : INTEGER ← 7 |
| TAX_RATE | REAL | 0.20 | CONST TAX_RATE : REAL ← 0.20 |
Constants are often used to define array bounds, record field sizes, or fixed limits.
CONST MAX_SIZE : INTEGER ← 100
CONST NAME_LENGTH : INTEGER ← 30
DECLARE scores[MAX_SIZE] : INTEGER
DECLARE studentRecord :
name : STRING[NAME_LENGTH]
id : INTEGER
mark : INTEGER
END RECORD
Once declared, a constant can appear in IF, CASE, loops, and procedures – exactly as a literal value would, but with the benefits listed above.
CONST PI : REAL ← 3.14159
CONST MAX_ITER : INTEGER ← 10
PROCEDURE areaOfCircle(radius : REAL) RETURNS REAL
RETURN PI * radius * radius
END PROCEDURE
PROCEDURE countDown()
FOR i ← MAX_ITER DOWNTO 1 DO
IF i MOD 2 = 0 THEN
DISPLAY "Even step: " & i
ELSE
DISPLAY "Odd step: " & i
END IF
END FOR
END PROCEDURE
PROCEDURE gradeMark(mark : INTEGER) RETURNS STRING
CASE mark OF
0..39: RETURN "F"
40..49: RETURN "D"
50..59: RETURN "C"
60..69: RETURN "B"
70..100: RETURN "A"
END CASE
END PROCEDURE
PI * 2²).Replacing hard‑coded “magic numbers” with named constants makes the code:
CONST – creates a variable that can be changed.= instead of ← – not Cambridge‑compliant.INTEGER constant).MAX_SPEED of type REAL with a value of 120.5.GRAVITY to compute the weight of an object given its mass (weight = mass × GRAVITY).CONST taxRate ← 0.15MAX_SIZE and use it to declare an integer array named scores. Then write a loop that initialises every element of scores to zero.1. CONST MAX_SPEED : REAL ← 120.5
2. PROCEDURE calculateWeight(mass : REAL) RETURNS REAL
RETURN mass * GRAVITY
END PROCEDURE
3. Error: identifier not in uppercase (convention) and type omitted (optional but clearer).
Corrected: CONST TAX_RATE : REAL ← 0.15
4. CONST MAX_SIZE : INTEGER ← 100
DECLARE scores[MAX_SIZE] : INTEGER
FOR i ← 1 TO MAX_SIZE DO
scores[i] ← 0
END FOR

CONST to declare a constant; optionally specify a type.←.Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.