Variables, constants and the five data types
A variable is a named store whose value can change as the program runs; a constant is a named value that is fixed (CONSTANT VAT = 0.20). The five basic data types: INTEGER (whole number), REAL (has a decimal part), CHAR (one character), STRING (many characters, or none) and BOOLEAN (TRUE/FALSE). "7" is a string; 7 is an INTEGER. Choosing a sensible type for the data is itself examined.
Three control structures; three loop types
Three control structures: sequence (statements in order), selection (IF ... THEN ... ELSE ... ENDIF or CASE OF ... ENDCASE) and iteration (a loop). Iteration has three forms: count-controlled (FOR ... NEXT, a known number of times), pre-condition (WHILE ... ENDWHILE, tested at the top — may run zero times) and post-condition (REPEAT ... UNTIL, tested at the bottom — always runs at least once). Nest at most three levels.
Operators, totalling, counting, strings
Arithmetic: + - * /, plus DIV (quotient: 17 DIV 5 = 3) and MOD (remainder: 17 MOD 5 = 2; Number MOD 2 = 0 tests even). Comparison ops give a BOOLEAN: = < <= > >= <> (<> is not equal to). Boolean: AND, OR, NOT. Totalling: Total ← Total + Value; counting: Count ← Count + 1 — both initialised to 0 before the loop. Strings: LENGTH, SUBSTRING, UCASE, LCASE; LENGTH counts every character, spaces included.
Drawn from real examiner reports.
Variable vs constant: state can-change
A variable holds a value that can change as the program runs; a constant holds a value that is fixed (one place to update, e.g. a tax rate). Saying only where each is used ("a variable is used in the calculation") earns no mark — state that one can change and the other cannot. This change/no-change property is the marked point.
November 2023 Paper 22 Q5 and Q7: most scored only partial marks because they described where variables would be used rather than the can-change / cannot-change distinction; "very few achieved all four marks".
Confusing the primitive data types
Match each type to what it holds: INTEGER = whole number, REAL = has a decimal part, CHAR = exactly one character, STRING = many characters, BOOLEAN = TRUE/FALSE. Common slips: choosing STRING for a number you calculate with, INTEGER for money (should be REAL), or CHAR where a multi-character STRING is needed.
November 2023 Paper 21 Q3: some candidates showed a lack of understanding of the primitive data types when matching a type to its description.
Write pseudocode, not program code
Where a question asks for an algorithm, use the syllabus pseudocode functions — UCASE, LCASE, LENGTH, SUBSTRING — not a language's .upper() or len(). An answer written in a specific programming language earns nothing when pseudocode is required. Match the published Cambridge style: ←, INPUT, OUTPUT, IF ... ENDIF, FOR ... NEXT.
June 2023 Paper 21 Q8(a): only a few used the correct pseudocode uppercase function — many wrote program code instead.
MOD vs DIV: remainder vs quotient
DIV gives the whole-number quotient; MOD gives the remainder of integer division. 17 DIV 5 = 3 and 17 MOD 5 = 2. Swapping them is a common slip — remember MOD is what is left over. A handy test: Number MOD 2 = 0 is true only when Number is even.
November 2023 Paper 23 Q2: MOD was examined as the correct operator (a known confusion with DIV).
Uninitialised total or counter
A totalling variable must start at 0 (Total ← 0) and a counter at 0 (Count ← 0) before the loop. In a trace table this means writing the starting 0 in the first row; omitting it makes every later value wrong and is frequently penalised.
November 2023 Paper 22 Q6(a) trace table: a common error was not initialising totalling/counting variables.
LENGTH counts all characters
LENGTH returns the number of characters in a string, counting every character — spaces and punctuation included, not just the letters. LENGTH("Hi there") = 8, not 7. Counting only the letters of a phrase gives the wrong length and loses the mark.
June 2023 Paper 21 Q8(b): a few incorrectly counted only the letters of the phrase when finding string length.
Trace with a column per variable
Draw a trace table with one column per variable plus an OUTPUT column. Write initial values first (total and counter at 0), then work line by line, changing only the column that changes. Copy the OUTPUT exactly — add no extra commas or quotes.
Choosing the right loop type
Pick the loop by asking: Is the repeat count known in advance? → count-controlled FOR. Must the body run at least once? → post-condition REPEAT ... UNTIL (tested at the bottom). Might it run zero times? → pre-condition WHILE ... ENDWHILE (tested at the top).
Answer only what is asked
Do exactly what the question requires — no more. If it asks for a double-entry check (input twice, compare, re-enter if different), do not bolt on a range check or other validation it did not request. Extra logic earns no marks and risks introducing new errors.
Read the whole scenario first
Read the whole scenario before writing. If it says the variables or arrays are already declared, do not re-declare them — use them as given. Re-declaring wastes time. Answer pseudocode questions in syllabus pseudocode, not program code.
This topic is the foundation of Paper 2 (Algorithms, Programming and Logic). You write and read Cambridge pseudocode: ← is assignment, OUTPUT displays a value, loops use FOR ... NEXT, WHILE ... ENDWHILE and REPEAT ... UNTIL. Early Paper 2 questions are based directly on the published syllabus pseudocode, so learn its exact style.
Full notes, flashcards, Q&A and the topic quiz for every premium subject.
Premium plans are US$8.99/month or US$49.99/year — first month free.
Studying with a parent's blessing? Show them this.