← IGCSE Computer Science Paper 2

DIV: integer division

Returns how many whole times b goes into a, discarding any remainder. DIV(10, 3) gives 3, but 10 / 3 gives 3.333. Both values are integers.

Understanding DIV: integer division in IGCSE Computer Science Paper 2

What it does: 5 goes into 17 three whole times, so this outputs 3 and the remainder 2 is ignored. The / operator keeps the fractional part, while DIV discards it and returns only the whole quotient. DIV(30, 4) returns 7 whole groups. 30 / 4 gives 7.5, which is not a whole number of groups. DIV never rounds. DIV(19, 10) is 1, not 2, because the fractional part .9 is simply thrown away. In Cambridge pseudocode, DIV is written as a function with brackets: DIV(a, b). Both values must be integers. Full teams must be whole numbers, so use DIV. The 2 players left over are found with MOD, not DIV.

Common mistakes: 10 / 3 gives 3.333, a REAL value, which cannot be stored in an INTEGER variable. DIV(10, 3) gives the whole number 3, so the line should be Groups ← DIV(10, 3). The arguments are the wrong way round. DIV(a, b) is how many times b goes into a. Here it should be DIV(50, BoxSize), which gives 8 boxes. The broken line gives 0.

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 DIV(10, 3) return?
3.3333
Matches
result ← DIV(10, 3) // result is 3.333
↓
DIV discards the fractional part, so DIV(10, 3) is 3, not 3.333. Only the / operator would give 3.333.
Applying
Meanings
Term
DIV(a, b)
Meaning
Returns how many whole times b goes into a, discarding any remainder. DIV(10, 3) gives 3, but 10 / 3 gives 3.333. Both values are integers.
Practice
DECLARE Students : INTEGER
Testing
Gaps
OUTPUT (10, 3)
Check Answer
Spots
1DECLARE Groups : INTEGER
2Groups ← 10 / 3

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

The 'Fox' badge — Cunning Debugger, 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.333
B. 3 ✓
DIV gives the whole number of times 3 goes into 10 and discards the fractional part, so the answer is 3.
2. Which expression gives the number of whole groups of 4 that can be made from 30 students?
A. DIV(30, 4) ✓
B. 30 / 4
DIV(30, 4) returns 7 whole groups. 30 / 4 gives 7.5, which is not a whole number of groups.
3. DIV(17, 5) returns:
A. 3 ✓
B. 4
5 goes into 17 three whole times (15). DIV does not round up, it just discards the fractional part.
4. Which statement about DIV is true?
A. It rounds the result to the nearest whole number
B. It discards the fractional part of the result ✓
DIV never rounds. DIV(19, 10) is 1, not 2, because the fractional part .9 is simply thrown away.
5. Which pseudocode correctly uses DIV?
A. Groups ← DIV(25, 6) ✓
B. Groups ← 25 DIV 6.0
In Cambridge pseudocode, DIV is written as a function with brackets: DIV(a, b). Both values must be integers.

Match the Pairs

DIV(10, 3) → Returns 3, because 3 goes into 10 three whole times and the remainder is discarded
groups ← DIV(25, 4) → Stores 6 in groups, the number of whole groups of 4 that fit into 25
DIV gives the whole number of times one integer goes into another, ignoring the remainder → OUTPUT DIV(17, 5)
Dividing with / can give a decimal answer, but DIV always gives a whole number → 10 / 3 gives 3.333 but DIV(10, 3) gives 3
result ← DIV(10, 3) // result is 3.333 → DIV discards the fractional part, so DIV(10, 3) is 3, not 3.333. Only the / operator would give 3.333.
buses ← DIV(50, 20) // buses is 3 → DIV does not round up. 20 goes into 50 only 2 whole times, so DIV(50, 20) is 2, not 3.

Key Term

DIV(a, b)
Returns how many whole times b goes into a, discarding any remainder. DIV(10, 3) gives 3, but 10 / 3 gives 3.333. Both values are integers.

Fill in the Blanks

1. // Displays 3 OUTPUT DIV(10, 3)
Hint: Type the function name that gives the whole number of times 3 goes into 10 and discards the remainder.
2. // 20 sweets, 4 sweets in each bag Bags ← DIV(20, 4)
Hint: Type the second argument: the size of each group, which divides the total.
3. DECLARE Groups : INTEGER Groups ← DIV(10, 3)
Hint: Type the data type that suits a whole-number result with no fractional part.
4. // Shows 3.3333... not a whole number OUTPUT 10 / 3
Hint: Type the ordinary division operator that keeps the fractional part, unlike DIV.
5. Pupils ← 25 TeamSize ← 4 Teams ← DIV(Pupils, TeamSize)
Hint: Type the variable that holds how many pupils go in each team.

Spot the Error

Question 1
A DECLARE Groups : INTEGER
B Groups ← 10 / 3
C OUTPUT Groups
Line B — 10 / 3 gives 3.333, a REAL value, which cannot be stored in an INTEGER variable. DIV(10, 3) gives the whole number 3, so the line should be Groups ← DIV(10, 3).
Question 2
A CONSTANT BoxSize ← 6
B DECLARE Boxes : INTEGER
C Boxes ← DIV(BoxSize, 50)
D OUTPUT Boxes
Line C — The arguments are the wrong way round. DIV(a, b) is how many times b goes into a. Here it should be DIV(50, BoxSize), which gives 8 boxes. The broken line gives 0.
Question 3
A DECLARE Total, Teams : INTEGER
B Total ← 29
C Teams ← DIV(Total, 5)
D OUTPUT "Teams: " Teams
Line D — OUTPUT needs a comma between the items it prints. It should be OUTPUT "Teams: ", Teams, which shows 5.
Question 4
A DECLARE Bags : INTEGER
B Bags ← DIV(47.5, 8)
C OUTPUT Bags
Line B — DIV only works with integers, and 47.5 is a REAL. The line should be Bags ← DIV(47, 8), which gives 5 whole bags.
Question 5
A DECLARE Rows : STRING
B Rows ← DIV(25, 4)
C OUTPUT Rows
Line A — DIV returns a whole number, so Rows must be declared as INTEGER. A STRING variable cannot hold the result 6. It should be DECLARE Rows : INTEGER.

Student with a class code? Join your class →