The vocabulary of programming. Variables and constants, the five data types, INPUT and OUTPUT, arithmetic and logic operators, and how a program runs top to bottom in sequence. Every line of code you'll ever write starts here.
Read this before you tap the activities. These notes give you everything you need to feel confident before the Program Playground. When you're ready, tap 🎓 Learn.
Every program you'll ever write is built from a small set of ideas: variables and constants that store data, data types that describe what kind of data (whole numbers, decimals, text, single characters, TRUE/FALSE), INPUT and OUTPUT statements that talk to the user, arithmetic operators that calculate, and sequence — the rule that says programs run top to bottom. Get these five ideas locked in and every Paper 2 program question opens up.
By the end of Topic 8.1–8.5 you should be able to…
| Term | One-line definition |
|---|---|
| Variable | A named memory location whose value CAN change while the program runs. |
| Constant | A named memory location whose value CANNOT change once assigned. |
| Identifier | The name given to a variable, constant, procedure or function. |
| Data type | The category of data a variable holds: INTEGER, REAL, STRING, CHAR, BOOLEAN. |
| Assignment | Storing a value into a variable, using the <- operator in Cambridge pseudocode. |
| INPUT | Cambridge keyword to read a value from the user into a variable. |
| OUTPUT | Cambridge keyword to display a value (or values) to the user. |
| Sequence | The rule that a program executes lines top to bottom in order, unless a control structure changes the flow. |
| MOD | The remainder operator. 17 MOD 5 = 2. |
| DIV | The integer division operator. 17 DIV 5 = 3. |
| Type | Stores | Example values |
|---|---|---|
| INTEGER | Whole numbers | 7, 0, -42, 1000 |
| REAL | Decimal numbers | 3.14, -0.5, 2.0, 99.99 |
| STRING | Text (multiple characters) | "hello", "cat123", "" |
| CHAR | A single character | 'A', '?', ' ', '7' |
| BOOLEAN | Two states only: TRUE or FALSE | TRUE, FALSE |
| Operator | Meaning | Example |
|---|---|---|
| + | Addition | 3 + 4 = 7 |
| - | Subtraction | 10 - 3 = 7 |
| * | Multiplication | 5 * 2 = 10 |
| / | Division (real result) | 10 / 4 = 2.5 |
| MOD | Remainder after division | 17 MOD 5 = 2 |
| DIV | Whole part of division | 17 DIV 5 = 3 |
| Operator | Meaning |
|---|---|
| = | Equal to |
| <> | Not equal to |
| <, >, <=, >= | Less than, greater than, and their "or equal" versions |
| AND | Both conditions must be true |
| OR | At least one condition must be true |
| NOT | Reverses TRUE/FALSE |
Store a person's name and age, then output them.
DECLARE Name : STRING DECLARE Age : INTEGER Name <- "Alex" Age <- 15 OUTPUT Name, " is ", Age, " years old"
Note the syntax: DECLARE Name : STRING (colon, space, capital keyword). The assignment operator is <-, not =.
Turn 347 pence into pounds and pence:
DECLARE Pence, Pounds, Change : INTEGER Pence <- 347 Pounds <- Pence DIV 100 // 347 DIV 100 = 3 Change <- Pence MOD 100 // 347 MOD 100 = 47 OUTPUT Pounds, " pounds ", Change, " pence"
Output: 3 pounds 47 pence. DIV = whole part. MOD = remainder.
Cambridge uses STRING. "text" is not accepted. Nor is "number" (use INTEGER or REAL), "bool" (use BOOLEAN), or "letter" (use CHAR).
INPUT reads FROM the user INTO a variable. OUTPUT writes FROM a variable TO the screen. Examiners flag "an output that should have been an input" every session.
The Cambridge assignment operator is <- (left arrow). Using = is a syntax error in Cambridge pseudocode — = is only for comparison.
Names like x, data, Array or temp are marked "not meaningful". Use names that describe the value: StudentAge, TotalPrice, UserName.
DIV gives the whole part of a division (17 DIV 5 = 3). MOD gives the remainder (17 MOD 5 = 2). Learn them as a pair.
Mark-winning tips from the 2023–2025 examiner reports:
DECLARE Name : STRING is the syntax.StudentAge, not x or data.Tap each question to reveal the answer. Aim for at least 5 of 6.
Name the five data types. Explain variable vs constant. Write a DECLARE line correctly. Know that <- is assignment. Predict MOD and DIV results for small numbers.
Ready? Tap the 🎓 Learn tab and try the Program Playground — step through three real programs and watch memory update live.
Programs store data in named spaces in memory. A variable can change during execution; a constant cannot. Every value has a data type — Cambridge uses exactly five: INTEGER (whole numbers), REAL (decimals), STRING (text), CHAR (one character), BOOLEAN (TRUE/FALSE). Programs read values with INPUT, calculate with arithmetic operators, and display results with OUTPUT. Everything runs top to bottom in sequence — that's the default flow you'll build on with selection (8.6) and iteration (8.7) later.
Grab a scrap of paper. Draw five boxes labelled Name, Age, Height, Initial, Adult. Write "Alex" in Name, 15 in Age, 1.73 in Height, 'A' in Initial, and TRUE in Adult. Ask a friend: for each box, what data type is Cambridge asking for? (Answers: STRING, INTEGER, REAL, CHAR, BOOLEAN.) That's the mental model of memory — variables are boxes, and each box has a type.
Every professional programming language enforces data types — even ones that feel "typeless" like Python check them at runtime. Getting types wrong is the number-one cause of bugs in real software: adding a string to a number, storing text where a number should go, or truncating a REAL to an INTEGER by accident. The habit of choosing the right type on day one saves hours of debugging later.
Why does Cambridge require you to declare a variable's type before using it? Some languages (Python, JavaScript) let you skip this — why do you think Cambridge insists on it? What's gained, what's lost?
Both are named memory locations. The difference is whether the value can change while the program runs.
Value CAN change during execution.
Use for: user input, counters, running totals, results of calculations, anything that varies.
Cambridge syntax: DECLARE Age : INTEGER
Assign: Age <- 15 then later Age <- Age + 1
Value CANNOT change once set.
Use for: mathematical values (π, e), physical constants (speed of light), settings that never vary during a run (VAT rate, screen width).
Cambridge syntax: CONSTANT Pi = 3.14
Try to change it and: the program errors — that's the point.
Pick a program. Click Step. The current line highlights; variables appear as memory boxes; output prints below. This is exactly how a debugger works in a real IDE.
No variables yet. Click Step to declare the first one.
The exact syntax examiners expect.
"Some candidates incorrectly used text as a data type." Cambridge uses STRING. Also flagged: "number", "bool", "letter". Learn the exact five names.
Cited: 2025 s25 Q2 examiner report — verbatim"Many candidates used Array as the identifier for the array, which is not considered meaningful." Same for x, data, temp. Use names that describe the value.
"Errors included… an output that should have been an input." A classic exam question — spot the wrong direction.
Cited: 2025 w25 error-finding questionUsing = for assignment is Python/Java thinking. Cambridge uses <-. = is only for equality comparison.
"Most candidates were able to identify the correct purpose of MOD and DIV with only a few giving the correct pseudocode." Practise writing the actual expression, not just describing what they do.
Cited: 2025 s25 Q5 examiner report — verbatimIf the question says "declare and use", you must include the DECLARE line with the correct type. Skipping the declaration and going straight to the assignment loses the declaration mark. Note: if the question already declares the variables, don't re-declare — use them as given.
A value or description is shown. Which of the five Cambridge data types is it?
A use case is shown. Would you declare it as a variable or a constant?
Predict the result of an arithmetic expression. Tests MOD and DIV.
A pseudocode line has an error. Pick the fix.
10 rapid questions on data types, operators, syntax. Beat your best.
Every question below is drawn from a real Cambridge Paper 2 (2022–2025) or the examiner report describing that question. Type your answer, then reveal the model.
Cambridge uses STRING. Also: INTEGER not "number", BOOLEAN not "bool", CHAR not "letter".
2025 s25 Q2 examiner report — verbatimUse names that describe the value: StudentAge, TotalPrice, HighestMark.
2024 w24 Q6(c), recurringWatch the direction. INPUT reads FROM user; OUTPUT writes TO screen.
2025 w25 error-finding questionCambridge uses <-. The = is only for equality comparison.
Recurring across 2023–2025"Most candidates were able to identify the correct purpose of MOD and DIV with only a few giving the correct pseudocode." Practise the syntax.
2025 s25 Q5 examiner report — verbatimIf the question expects declaration, don't skip it. If the question already declares variables in the scenario, use them as given — don't re-declare.
2025 s25 general comments"Errors included an incorrect data type in one of the declaration statements." Match the type to what the variable actually stores.
2025 w25 error-finding question — verbatim"Some candidates reversed the notation for NOT X with X NOT." NOT comes BEFORE the variable/condition.
2024 w24 Q7(a) — verbatimIf the scenario names variables (e.g. StudentScores), use those exact names. Making up your own loses marks.
2025 w25 general commentsThe five Cambridge data types.
INTEGER · REAL · STRING · CHAR · BOOLEAN. Learn as one string.
The Cambridge arithmetic pair. 17 MOD 5 = 2 (what's left over). 17 DIV 5 = 3 (how many times it divides).
Assignment operator.
Cambridge uses <-. Python-style = is a syntax error. The = is only for equality comparison.
Pick the right one.
Variable: score, counter, user input. Constant: π, VAT rate, max size — set once, never changes.
Never x, data, Array, temp.
Use StudentAge, TotalPrice, HighestMark, CurrentYear. If your identifier doesn't describe what it holds, rename it.
Green = secured (≥70%). Yellow = focus (30–69%). Grey = not attempted. Tap any badge to override.