MOD function
Returns the remainder when a is divided by b. For example MOD(10, 3) gives 1. MOD(n, 2) = 0 means n is even.
Understanding MOD function in IGCSE Computer Science Paper 2
What it does: MOD(a, b) gives the remainder of a divided by b. 5 goes into 17 three times (15), so MOD(17, 5) returns 2. An odd number leaves a remainder of 1 when divided by 2, so MOD(Num, 2) = 1 tests for odd. MOD gives the remainder. DIV gives the whole-number part of the division (the quotient). An even number divides by 2 with no remainder, so MOD(n, 2) = 0. A result of 1 means n is odd. MOD is used as a function with two values in brackets: MOD(17, 5), which gives 2. Cambridge pseudocode does not write it in the other form.
Common mistakes: MOD(Number, 2) = 0 means there is no remainder when dividing by 2, so the number is even. The output should be "Even". A remainder of 1 when dividing by 2 means the number is odd. To test for even numbers the condition must be MOD(Number, 2) = 0.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 27–36) and word search (Modules 27–46).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
MOD(a, b)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →