← IGCSE Computer Science Paper 2

DIV function

Returns the whole-number quotient of a divided by b, discarding the fractional part. For example, DIV(10, 3) returns 3. Both a and b are integers.

Understanding DIV function in IGCSE Computer Science Paper 2

What it does: DIV gives the whole number of times 60 fits into Minutes, ignoring any leftover minutes. DIV discards the fractional part, so only complete packs of 6 are counted. DIV returns the quotient. The remainder is what MOD returns. DIV(30, 4) gives 7 whole groups. The / operator gives 7.5, which keeps the fractional part. DIV works on whole numbers, for example DIV(10, 3). Both a and b are integers. 10 divided by 3 is 3.33..., and DIV keeps only the whole number 3. 17 / 5 = 3.4, and DIV discards the .4 so the result is 3.

Common mistakes: MOD gives the remainder (2), not the whole-number quotient. To find how many whole groups of 5 fit into 17, use DIV(Total, 5), which returns 3. Left should hold the minutes remaining after the whole hours are taken away. That needs MOD(Minutes, 60), which gives 15. DIV would just repeat the 2 hours.

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 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.

Learning
Duo
What does DIV(10, 3) return?
3.333
Matches
Result ← DIV(7, 2) // Result is 3.5
↓
DIV discards the fractional part, so DIV(7, 2) is 3, not 3.5. Use 7 / 2 to get 3.5.
Applying
Meanings
Term
DIV(a, b)
Meaning
Returns the whole-number quotient of a divided by b, discarding the fractional part. For example, DIV(10, 3) returns 3. Both a and b are integers.
Practice
DECLARE Seconds : INTEGER
Testing
Gaps
OUTPUT (10, 3)
Check Answer
Spots
1Total ← 17
2Groups ← MOD(Total, 5)

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

The 'Void Whale' badge — Definition Drifter, 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.33
B. 3 ✓
DIV gives only the whole-number part of the division. 10 divided by 3 is 3 remainder 1, so DIV(10, 3) is 3.
2. Which description matches DIV(a, b)?
A. The whole-number quotient, with the fractional part discarded ✓
B. The remainder left over after dividing
DIV returns the quotient. The remainder is what MOD returns.
3. What does DIV(17, 5) return?
A. 3 ✓
B. 2
5 goes into 17 three whole times (15), so the answer is 3. The 2 is the remainder, which is the job of MOD.
4. What does DIV(9, 2) return?
A. 5
B. 4 ✓
DIV discards the fractional part (4.5), so the result is 4. It does not round up.
5. Which line stores the number of complete groups of 4 that fit into 30?
A. Groups ← DIV(30, 4) ✓
B. Groups ← 30 / 4
DIV(30, 4) gives 7 whole groups. The / operator gives 7.5, which keeps the fractional part.

Match the Pairs

DIV(10, 3) → Returns 3, the whole-number part of 10 divided by 3, with the remainder discarded
DIV(17, 5) → Returns 3, because 5 goes into 17 three whole times
Find how many whole 60-minute hours are in a number of minutes stored in Minutes → Hours ← DIV(Minutes, 60)
Find how many full packs of 6 can be made from Total eggs → FullPacks ← DIV(Total, 6)
Result ← DIV(7, 2) // Result is 3.5 → DIV discards the fractional part, so DIV(7, 2) is 3, not 3.5. Use 7 / 2 to get 3.5.
Left ← DIV(14, 4) // Left is 2, the remainder → DIV(14, 4) returns the quotient 3, not the remainder 2. The remainder is found with MOD(14, 4).

Key Term

DIV(a, b)
Returns the whole-number quotient of a divided by b, discarding the fractional part. For example, DIV(10, 3) returns 3. Both a and b are integers.

Fill in the Blanks

1. OUTPUT DIV(10, 3)
Hint: Type the function name that returns the whole-number quotient, ignoring any remainder.
2. OUTPUT DIV(17, 5) // gives 3
Hint: Type the divisor (second argument) that makes the whole-number result 3.
3. INPUT Minutes Hours ← DIV(Minutes, 60) OUTPUT Hours
Hint: Type the variable holding the value that is being divided (the first argument).
4. DECLARE Packs : INTEGER Packs ← DIV(50, 12) OUTPUT Packs
Hint: Type the data type keyword that suits a whole-number result from DIV.
5. Students ← 95 Rows ← DIV(Students, 10) OUTPUT Rows // shows 9
Hint: Type the divisor that gives a whole-number quotient of 9 when 95 is divided by it.

Spot the Error

Question 1
A Total ← 17
B Groups ← MOD(Total, 5)
C OUTPUT Groups
Line B — MOD gives the remainder (2), not the whole-number quotient. To find how many whole groups of 5 fit into 17, use DIV(Total, 5), which returns 3.
Question 2
A Minutes ← 135
B Hours ← DIV(Minutes, 60)
C Left ← DIV(Minutes, 60)
D OUTPUT Hours, Left
Line C — Left should hold the minutes remaining after the whole hours are taken away. That needs MOD(Minutes, 60), which gives 15. DIV would just repeat the 2 hours.
Question 3
A DECLARE Sweets : INTEGER
B Sweets ← 25
C Boxes ← Sweets DIV 4
D OUTPUT Boxes
Line C — In Cambridge pseudocode DIV is a function, not an infix operator. It must be written with brackets as DIV(Sweets, 4).
Question 4
A DECLARE Buses : STRING
B Buses ← DIV(100, 30)
C OUTPUT Buses
Line A — DIV returns a whole number (3), so the variable that stores it should be declared as INTEGER, not STRING.
Question 5
A INPUT Pupils
B Seats ← 4
C Tables ← DIV(Pupils)
D OUTPUT Tables
Line C — DIV needs two arguments: the number being divided and the divisor. It should be DIV(Pupils, Seats).

Student with a class code? Join your class →