← IGCSE Computer Science Paper 2

DIV and MOD

DIV(a, b) gives the whole-number part of a divided by b, so DIV(10, 3) is 3. MOD(a, b) gives the remainder, so MOD(10, 3) is 1. Both take integers.

Understanding DIV and MOD in IGCSE Computer Science Paper 2

What it does: An even number divides by 2 with no remainder, so MOD(Number, 2) equals 0. DIV gives the whole number of 60-minute blocks, which is the number of complete hours. MOD gives the remainder after dividing. 10 = 3 * 3 + 1, so MOD(10, 3) is 1. MOD returns the remainder. DIV returns the whole-number quotient and discards the remainder. 8 divides exactly by 2, so the remainder is 0. DIV(8, 2) would be 4. DIV(a, b) and MOD(a, b) work on integers, such as DIV(10, 3). They do not work on strings. MOD returns what is left over after dividing. 3 goes into 10 three times (9), leaving 1.

Common mistakes: The program should output the whole-number part of 10 divided by 3. MOD gives the remainder (1), not the whole part. It should be Part ← DIV(Number, 3), which gives 3. The variable holds the remainder, and the output should be 1. DIV(10, 3) gives 3, the whole-number part. The remainder needs MOD(10, 3).

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 146–155) and word search (Modules 146–165).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What does DIV(10, 3) return?
13
Matches
Minutes ← DIV(TotalMinutes, 60)
↓
DIV gives the whole hours, not the minutes left over. The leftover minutes need MOD(TotalMinutes, 60).
Applying
Meanings
Term
DIV(a, b) and MOD(a, b)
Meaning
DIV(a, b) gives the whole-number part of a divided by b, so DIV(10, 3) is 3. MOD(a, b) gives the remainder, so MOD(10, 3) is 1. Both take integers.
Practice
Hours ← DIV(Minutes, 60)
Testing
Gaps
OUTPUT (10, 3)
Check Answer
Spots
1Number ← 10
2Part ← MOD(Number, 3)

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

The 'Blobfish' badge — Pressure Handler, 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 DIV(10, 3) return?
A. 3 ✓
B. 1
DIV gives the whole-number quotient. 3 goes into 10 three times, so DIV(10, 3) is 3. The remainder 1 comes from MOD.
2. What does MOD(10, 3) return?
A. 1 ✓
B. 3
MOD gives the remainder after dividing. 10 = 3 * 3 + 1, so MOD(10, 3) is 1.
3. Which condition tests whether Number is even?
A. MOD(Number, 2) = 0 ✓
B. DIV(Number, 2) = 0
An even number has remainder 0 when divided by 2, so use MOD. DIV(Number, 2) = 0 is only true for 0 and 1.
4. Which function gives the leftover part after a division?
A. DIV
B. MOD ✓
MOD returns the remainder. DIV returns the whole-number quotient and discards the remainder.
5. A program splits 135 minutes into hours and minutes. Which gives the whole hours?
A. MOD(135, 60)
B. DIV(135, 60) ✓
DIV(135, 60) is 2 whole hours. MOD(135, 60) is 15, which is the minutes left over.

Match the Pairs

DIV(10, 3) → Gives the whole-number part of 10 divided by 3, which is 3
MOD(10, 3) → Gives the remainder when 10 is divided by 3, which is 1
Test whether the variable Number holds an even number → IF MOD(Number, 2) = 0 THEN
Convert TotalMinutes into whole hours (for example 135 minutes gives 2 hours) → Hours ← DIV(TotalMinutes, 60)
Minutes ← DIV(TotalMinutes, 60) → DIV gives the whole hours, not the minutes left over. The leftover minutes need MOD(TotalMinutes, 60).
IF DIV(Number, 2) = 0 THEN → DIV gives the quotient, not the remainder, so it cannot test for even. The test should use MOD(Number, 2) = 0.

Key Term

DIV(a, b) and MOD(a, b)
DIV(a, b) gives the whole-number part of a divided by b, so DIV(10, 3) is 3. MOD(a, b) gives the remainder, so MOD(10, 3) is 1. Both take integers.

Fill in the Blanks

1. OUTPUT DIV(10, 3)
Hint: Type the function that gives the whole-number part of a division.
2. OUTPUT MOD(10, 3)
Hint: Type the function that gives the remainder after dividing.
3. IF MOD(Number, 2) = 0 THEN OUTPUT "Even" ENDIF
Hint: Type the divisor you use to test whether a whole number is even.
4. Minutes ← 135 Hours ← DIV(Minutes, 60) OUTPUT Hours
Hint: Type the number of minutes in one hour.
5. Hours ← DIV(Minutes, 60) Left ← MOD(Minutes, 60) OUTPUT Left
Hint: Type the variable that holds the total being split, to find the minutes left over.

Spot the Error

Question 1
A Number ← 10
B Part ← MOD(Number, 3)
C OUTPUT "Whole part: ", Part
Line B — The program should output the whole-number part of 10 divided by 3. MOD gives the remainder (1), not the whole part. It should be Part ← DIV(Number, 3), which gives 3.
Question 2
A Remainder ← DIV(10, 3)
B OUTPUT Remainder
C // Output is 1
Line A — The variable holds the remainder, and the output should be 1. DIV(10, 3) gives 3, the whole-number part. The remainder needs MOD(10, 3).
Question 3
A INPUT Number
B // Test for an even number
C IF MOD(Number, 2) ← 0
D THEN
E OUTPUT "Even"
F ENDIF
Line C — A condition compares values, so it needs the comparison operator =. The assignment arrow ← cannot be used in an IF condition. It should be IF MOD(Number, 2) = 0.
Question 4
A INPUT TotalMinutes
B Hours ← DIV(TotalMinutes, 60)
C // Minutes left over
D Mins ← MOD(60, TotalMinutes)
E OUTPUT Hours, " h ", Mins
Line D — The arguments are the wrong way round. MOD(a, b) is the remainder of a divided by b, so the total minutes must come first. It should be Mins ← MOD(TotalMinutes, 60).
Question 5
A DECLARE Number : INTEGER
B Number ← 17
C Last ← MOD(Number)
D OUTPUT "Last digit: ", Last
Line C — MOD needs two arguments: the number and the divisor. The last digit is the remainder after dividing by 10, so it should be Last ← MOD(Number, 10).

Student with a class code? Join your class →