← IGCSE Computer Science Paper 2

Using DIV and MOD together (8.1c)

Use DIV and MOD on the same two numbers to split a value. DIV gives the whole units (2 hours) and MOD gives what is left over (30 minutes). Check: DIV * b + MOD gives a back.

Understanding Using DIV and MOD together (8.1c) in IGCSE Computer Science Paper 2

What it does: Whole units multiplied by the divisor, plus the remainder, always gives back the original number. An even number leaves a remainder of 0 when divided by 2, while an odd number leaves 1. MOD is the remainder. 150 minutes is 2 hours with 30 minutes left over, so MOD gives 30. Both calls must use the same two numbers in the same order. MOD(60, 150) gives 60, which is not the leftover minutes. Multiply the DIV result by 60 and add the MOD result. 3 * 60 + 20 = 200, so the split is correct. The leftover part of a split is found with MOD, so DIV here returns pounds rather than pence.

Common mistakes: The minutes left over are stored in Mins, but this line outputs Hours twice. It should be OUTPUT Hours, "h ", Mins, "m" so it shows 2h 30m. The arguments are the wrong way round. MOD(60, Total) gives 60 MOD 150 = 60, not the leftover minutes. It should be MOD(Total, 60), which gives 30.

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 429–438) and word search (Modules 419–438).

Take this worksheet further — free with Cloodit

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

Learning
Duo
You have 150 minutes and want the whole HOURS. Which one do you use?
MOD(150, 60), which gives 30DIV(150, 60), which gives 2
Matches
Pence ← DIV(275, 100)
↓
DIV gives the whole pounds (2), not the pence left over. To get the 75 pence, use MOD(275, 100).
Applying
Meanings
Term
DIV(150, 60) and MOD(150, 60)
Meaning
Use DIV and MOD on the same two numbers to split a value. DIV gives the whole units (2 hours) and MOD gives what is left over (30 minutes). Check: DIV * b + MOD gives a back.
Practice
TotalMinutes ← 150
Testing
Gaps
Minutes ← (150, 60)
Check Answer
Spots
3Mins ← MOD(TotalMinutes, 60)
4OUTPUT Hours, "h ", Hours, "m"

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

The 'Kraken' badge — Deep Sea Master, 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. You have 150 minutes and want the whole HOURS. Which one do you use?
A. MOD(150, 60), which gives 30
B. DIV(150, 60), which gives 2 ✓
DIV gives the whole number of 60s in 150, so that is 2 hours. MOD gives the 30 minutes left over.
2. What does MOD(150, 60) give when you split 150 minutes into hours and minutes?
A. 30, the minutes left over ✓
B. 2, the whole hours
MOD is the remainder. 150 minutes is 2 hours with 30 minutes left over, so MOD gives 30.
3. A price is 475 pence. Which pair splits it into pounds and pence?
A. Pounds = MOD(475, 100), Pence = DIV(475, 100)
B. Pounds = DIV(475, 100), Pence = MOD(475, 100) ✓
DIV(475, 100) = 4 whole pounds and MOD(475, 100) = 75 pence left over. The swapped version gives 75 pounds and 4 pence.
4. Which pair of calls splits 150 into hours and minutes correctly?
A. DIV(150, 60) and MOD(150, 60) ✓
B. DIV(150, 60) and MOD(60, 150)
Both calls must use the same two numbers in the same order. MOD(60, 150) gives 60, which is not the leftover minutes.
5. How can you check that DIV and MOD have split a number a by b correctly?
A. DIV(a, b) * b + MOD(a, b) gives a back ✓
B. DIV(a, b) + MOD(a, b) gives a back
Whole units times the size of each unit, plus what is left over, rebuilds a. For 150 and 60: 2 * 60 + 30 = 150.

Match the Pairs

Hours ← DIV(150, 60) → Stores the whole number of hours in 150 minutes, which is 2
Minutes ← MOD(150, 60) → Stores the minutes left over after taking out whole hours, which is 30
Check that DIV and MOD split a number correctly by rebuilding the original value a → DIV(a, b) * b + MOD(a, b) = a
Test whether a number is even by using MOD with 2 as the divisor → IF MOD(Number, 2) = 0 THEN
Pence ← DIV(275, 100) → DIV gives the whole pounds (2), not the pence left over. To get the 75 pence, use MOD(275, 100).
Minutes ← MOD(60, 150) → The numbers are in the wrong order. The total goes first and the divisor second, so it should be MOD(150, 60).

Key Term

DIV(150, 60) and MOD(150, 60)
Use DIV and MOD on the same two numbers to split a value. DIV gives the whole units (2 hours) and MOD gives what is left over (30 minutes). Check: DIV * b + MOD gives a back.

Fill in the Blanks

1. Hours ← DIV(150, 60) Minutes ← MOD(150, 60)
Hint: Type the library routine that gives the remainder, the minutes left over after the whole hours.
2. Hours ← DIV(TotalMinutes, 60) Minutes ← MOD(TotalMinutes, 60)
Hint: Type the library routine that gives the whole number of hours.
3. Pounds ← DIV(Pence, 100) LeftOver ← MOD(Pence, 100)
Hint: Type the number of pence in one pound, the same divisor DIV uses.
4. Check ← DIV(a, b) * b + MOD(a, b)
Hint: Type the arithmetic operator that multiplies the whole-number quotient by b.
5. IF MOD(Number, 2) = 1 THEN OUTPUT "Odd" ENDIF
Hint: Type the remainder that an odd number leaves when divided by 2.

Spot the Error

Question 1
A TotalMinutes ← 150
B Hours ← DIV(TotalMinutes, 60)
C Mins ← MOD(TotalMinutes, 60)
D OUTPUT Hours, "h ", Hours, "m"
Line D — The minutes left over are stored in Mins, but this line outputs Hours twice. It should be OUTPUT Hours, "h ", Mins, "m" so it shows 2h 30m.
Question 2
A Total ← 150
B Hours ← DIV(Total, 60)
C Mins ← MOD(60, Total)
D OUTPUT Hours, "h ", Mins, "m"
Line C — The arguments are the wrong way round. MOD(60, Total) gives 60 MOD 150 = 60, not the leftover minutes. It should be MOD(Total, 60), which gives 30.
Question 3
A Pence ← 275
B Pounds ← DIV(Pence, 100)
C Left ← MOD(Pence, 100)
D Check ← Pounds * 10 + Left
E OUTPUT Check
Line D — The check must multiply DIV by the same number used in DIV and MOD, which is 100. It should be Pounds * 100 + Left, which gives back 275.
Question 4
A INPUT Number
B IF DIV(Number, 2) = 0 THEN
C OUTPUT "Even"
D ELSE
E OUTPUT "Odd"
F ENDIF
Line B — DIV gives the whole-number quotient, not the remainder. To test for even you need the remainder, so it should be IF MOD(Number, 2) = 0 THEN.
Question 5
A A ← 150
B Q ← DIV(A, 60)
C R ← MOD(A, 50)
D Check ← Q * 60 + R
Line C — DIV and MOD must use the same divisor. DIV uses 60, so MOD must also use 60. It should be R ← MOD(A, 60), otherwise Q * 60 + R will not give back A.

Student with a class code? Join your class →