Programming · 4 question types
Past paper frequency (2018 to 2024)
This topic accounts for approximately 13% of your exam marks.
Paper 2 is almost entirely programming. Variable types, assignments, loops and conditionals are tested every session.
CIE pseudocode supports the standard arithmetic operators, plus two specific to integer division.
| Operation | Pseudocode | Python |
|---|---|---|
| Addition | + | + |
| Subtraction | - | - |
| Multiplication | * | * |
| Division | / | / |
| Integer division (quotient) | DIV | // |
| Modulus (remainder) | MOD | % |
| Exponentiation (to the power of) | ^ | ** |
DIV returns the whole-number part of a division, throwing away any remainder.
17 DIV 5 = 3 (because 17 ÷ 5 = 3 remainder 2)
20 DIV 4 = 5 (because 20 ÷ 4 = 5 exactly)
9 DIV 2 = 4 (because 9 ÷ 2 = 4 remainder 1)
Useful for splitting things into equal groups: "how many full minutes are in 130 seconds?" → 130 DIV 60 = 2.
MOD returns the remainder after a division.
17 MOD 5 = 2 (17 ÷ 5 = 3 remainder 2)
20 MOD 4 = 0 (20 ÷ 4 = 5 remainder 0)
9 MOD 2 = 1 (9 ÷ 2 = 4 remainder 1)
Useful for a classic check: "is N divisible by 2?" → N MOD 2 = 0 is true for even numbers.
Example — A program is given a time in seconds. Calculate how many full minutes and how many leftover seconds it represents.
TotalSeconds ← 130
Minutes ← TotalSeconds DIV 60 // 2
Seconds ← TotalSeconds MOD 60 // 10
OUTPUT Minutes, " minutes and ", Seconds, " seconds"
Output: 2 minutes and 10 seconds.
The pattern of DIV for the whole part and MOD for the remainder appears all over programming: hours / minutes / seconds, pounds / pence, ticking time clocks, and many others.