← IGCSE Computer Science Paper 2

MOD: remainder (8.1a)

MOD(a, b) gives the remainder when integer a is divided by integer b, so MOD(10, 3) is 1. A result of 0 means exact division. MOD(n, 2) is 0 for even n and 1 for odd n.

Understanding MOD: remainder (8.1a) in IGCSE Computer Science Paper 2

What it does: Even numbers divide exactly by 2, so MOD(n, 2) is 0 for every even n. MOD(17, 5) gives the remainder 2, and the assignment arrow stores it in Left. 10 divided by 3 is 3 remainder 1. MOD gives the remainder, not the whole number part (that is DIV). 4 goes into 12 exactly 3 times with nothing left over, so the remainder is 0. 3 would be the DIV result. A remainder of 0 means exact division, for example MOD(15, 5) = 0. 7 divided by 2 is 3 remainder 1, so 7 is odd and MOD(7, 2) is 1.

Common mistakes: MOD(10, 3) gives the whole number 1, so Rem must be declared as INTEGER. A STRING variable cannot hold an integer remainder. It should be DECLARE Rem : INTEGER. In Cambridge pseudocode MOD is a function, not an operator placed between values. It should be Rem ← MOD(Num, 5), which gives 2.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 337–346) and word search (Modules 337–357).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does MOD(10, 3) return?
13
Matches
Rest ← MOD 10, 3
↓
MOD is a function, so its two values must be in brackets: MOD(10, 3).
Applying
Meanings
Term
MOD(10, 3)
Meaning
MOD(a, b) gives the remainder when integer a is divided by integer b, so MOD(10, 3) is 1. A result of 0 means exact division. MOD(n, 2) is 0 for even n and 1 for odd n.
Practice
DECLARE Number : INTEGER
Testing
Gaps
Remainder ← (10, 3)
Check Answer
Spots
1DECLARE Rem : INTEGER
2DECLARE Rem : STRING

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Clownfish' badge — Reef Rookie, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does MOD(10, 3) return?
A. 1 ✓
B. 3
10 divided by 3 is 3 remainder 1. MOD gives the remainder, not the whole number part (that is DIV).
2. What does MOD(12, 4) return?
A. 3
B. 0 ✓
4 goes into 12 exactly 3 times with nothing left over, so the remainder is 0. 3 would be the DIV result.
3. Which statement about MOD is true?
A. MOD(a, b) gives the remainder after dividing a by b ✓
B. MOD(a, b) gives the whole number part of a divided by b
MOD gives the remainder. DIV gives the whole number part (the quotient).
4. What does a MOD result of 0 tell you?
A. The first number divides exactly by the second ✓
B. The first number is smaller than the second
A remainder of 0 means exact division, for example MOD(15, 5) = 0.
5. Which check tests whether a number n is even?
A. MOD(n, 2) = 1
B. MOD(n, 2) = 0 ✓
Even numbers divide exactly by 2, so the remainder is 0. A remainder of 1 means n is odd.

Match the Pairs

MOD(10, 3) → Gives 1, because 10 divided by 3 is 3 with a remainder of 1
MOD(12, 4) → Gives 0, because 4 divides into 12 exactly with nothing left over
Check whether a whole number n is even by testing for a remainder of 0 when divided by 2 → IF MOD(n, 2) = 0 THEN
Store the remainder of 17 divided by 5 in a variable called Left → Left ← MOD(17, 5)
Rest ← MOD 10, 3 → MOD is a function, so its two values must be in brackets: MOD(10, 3).
Answer ← MOD(10, 3) // gives 3 → The comment is wrong: MOD gives the remainder, which is 1, not the whole-number part 3 (that is DIV).

Key Term

MOD(10, 3)
MOD(a, b) gives the remainder when integer a is divided by integer b, so MOD(10, 3) is 1. A result of 0 means exact division. MOD(n, 2) is 0 for even n and 1 for odd n.

Fill in the Blanks

1. Remainder ← MOD(10, 3)
Hint: Type the function name that returns the remainder of a division.
2. Rest ← MOD(10, 3) OUTPUT Rest
Hint: Type the variable that holds the remainder so it can be displayed.
3. IF MOD(Number, 2) = 0 THEN OUTPUT "Even" ENDIF
Hint: Type the divisor used to test whether a number is even.
4. IF MOD(Number, 2) = 1 THEN OUTPUT "Odd" ENDIF
Hint: Type the remainder value that shows a number is odd.
5. IF MOD(12, 4) = 0 THEN OUTPUT "Divides exactly" ENDIF
Hint: Type the remainder value that means exact division with nothing left over.

Spot the Error

Question 1
A DECLARE Rem : INTEGER
B DECLARE Rem : STRING
C OUTPUT Rem
Line B — MOD(10, 3) gives the whole number 1, so Rem must be declared as INTEGER. A STRING variable cannot hold an integer remainder. It should be DECLARE Rem : INTEGER.
Question 2
A Num ← 17
B Rem ← MOD(Num, 5)
C Rem ← Num MOD 5
Line C — In Cambridge pseudocode MOD is a function, not an operator placed between values. It should be Rem ← MOD(Num, 5), which gives 2.
Question 3
A IF Rem = 1
B Rem ← MOD(Number, 2)
C IF Rem = 0
D THEN OUTPUT "Even"
E ENDIF
Line A — A remainder of 0 when dividing by 2 means the number is even. Testing for 1 would print Even for odd numbers. It should be IF Rem = 0.
Question 4
A Total ← 25
B Left ← MOD(10, Total)
C OUTPUT Left
Line B — The arguments are swapped. MOD(a, b) is the remainder of a divided by b, so the number being divided comes first. It should be MOD(Total, 10), which gives 5.
Question 5
A DECLARE Left : INTEGER
B Minutes ← 135
C Hours ← Minutes DIV 60
D Left ← MOD(Hours, 60)
E OUTPUT Hours, Left
Line D — The minutes left over come from the remainder of the total minutes divided by 60, not from Hours. It should be Left ← MOD(Minutes, 60), which gives 15.

Student with a class code? Join your class →