Assignment – the operation that stores the result of an expression in a variable, using the operator :=.
Variable name – an identifier that follows the board’s naming rules.
Type‑compatible – the right‑hand side expression must be of the same data type as the variable, or be one of the permitted implicit conversions.
Constant – a named value that cannot be altered after its initial definition; it may appear on the right‑hand side of := but never on the left.
Built‑in function – a predefined operation (e.g. LEN(), INT()) that can be used in an expression.
Although many exam questions omit explicit declarations, the board expects you to understand the syntax.
| Purpose | Pseudocode |
|---|---|
| Declare an integer variable | INTEGER counter |
| Declare and initialise a real variable | REAL radius := 3.5 |
Define a constant (cannot be on the left‑hand side of :=) | CONST PI := 3.14159 |
| Declare an array of five integers | INTEGER marks[5] |
| Declare a record type | |
The assignment operator in Cambridge pseudocode is :=. The general form is:
variable := expressionAfter execution, variable holds the value produced by expression. A statement may be terminated with a semicolon (;) when the exam specification requires it.
_).IF, FOR, PROCEDURE, BEGIN, END).| Data Type | Literal Example | Description |
|---|---|---|
| Integer | 42 | Whole numbers, positive or negative. |
| Real | 3.14 | Numbers with a fractional part. |
| Boolean | TRUE, FALSE | Logical values. |
| String | "Hello" | Sequence of characters enclosed in double quotes. |
Only the following implicit conversions are allowed:
| From (source) | To (target) | Result |
|---|---|---|
| Integer | Real | Integer automatically becomes a real (e.g. 5 := 5.0). |
| Character | String | Single character becomes a one‑character string. |
| Boolean | Integer / Real | TRUE → 1, FALSE → 0. |
All other conversions cause a type error.
INT()) or redesign the expression.INTEGER ageage := 18
INTEGER a, b, suma := 7
b := 5
sum := a + b // sum now holds 12
INTEGER countercounter := 0
counter := counter + 1 // increment
counter := counter * 2 // double
INTEGER scores[5]i := 3
scores[i] := 87 // stores 87 in the 4th element (indexing starts at 0)
RECORD studentSTRING name
INTEGER mark
END RECORD
student := NEW student
student.name := "Bob"
student.mark := 73
REAL radius, arearadius := 3.5
area := 3.14159 * radius * radius // πr²
STRING firstName, lastName, fullNamefirstName := "Ada"
lastName := "Lovelace"
fullName := firstName & " " & lastName // "Ada Lovelace"
INTEGER scoreBOOLEAN isPass
score := 78
isPass := score >= 50 // TRUE
a, b, c := 1, 2, 3 // a=1, b=2, c=3INTEGER markBOOLEAN passed
READ mark // input from the user
passed := mark >= 40 // assign result of comparison
WRITE "Passed? ", passed // output TRUE/FALSE
STRING nameINTEGER length
READ name
length := LEN(name) // LEN returns the number of characters
WRITE "The name has ", length, " letters."
Below is a compact algorithm that demonstrates declaration, input, assignment, a loop, array usage and output.
PROCEDURE ReadMarksAndTotalINTEGER i, total
INTEGER marks[5]
total := 0
FOR i FROM 0 TO 4 DO
READ marks[i] // input each mark
total := total + marks[i] // accumulate using assignment
ENDFOR
WRITE "Total of the 5 marks = ", total
END PROCEDURE
= instead of := for assignment.counter and initialise it to 0.TRUE in a Boolean variable passed if the mark is 40 or above.REAL length, width, area, assign the product of length and width to area.greeting that concatenates the word “Hello”, a space, and a variable name (which already holds a student's name).x, y, z to the values 10, 20, and 30 respectively.marks[5] using a loop.student with fields name (STRING) and score (INTEGER), write pseudocode that updates student.score to the value stored in variable newScore.word, uses the built‑in function LEN() to find its length, and writes “Length = ” followed by the length.REAL).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.