DIV function

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

DIV function

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does DIV(10, 3) return?
A 3.33
B 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
3. What does DIV(17, 5) return?
A 3
B 2
4. What does DIV(9, 2) return?
A 5
B 4
5. Which line stores the number of complete groups of 4 that fit into 30?
A Groups ← DIV(30, 4)
B Groups ← 30 / 4

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

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

Definitions

DIV(a, b)

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
OUTPUT ___(10, 3)
2.
OUTPUT DIV(17, _) // gives 3
3.
INPUT Minutes Hours ← DIV(_______, 60) OUTPUT Hours
4.
DECLARE Packs : _______ Packs ← DIV(50, 12) OUTPUT Packs
5.
Students ← 95 Rows ← DIV(Students, __) OUTPUT Rows // shows 9

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Total ← 17
B Groups ← MOD(Total, 5)
C OUTPUT Groups
Question 2
A Minutes ← 135
B Hours ← DIV(Minutes, 60)
C Left ← DIV(Minutes, 60)
D OUTPUT Hours, Left
Question 3
A DECLARE Sweets : INTEGER
B Sweets ← 25
C Boxes ← Sweets DIV 4
D OUTPUT Boxes
Question 4
A DECLARE Buses : STRING
B Buses ← DIV(100, 30)
C OUTPUT Buses
Question 5
A INPUT Pupils
B Seats ← 4
C Tables ← DIV(Pupils)
D OUTPUT Tables

Answer Key

DIV function
Section A: Quick Questions
Q1
B — 3
Q2
A — The whole-number quotient, with the fractional part discarded
Q3
A — 3
Q4
B — 4
Q5
A — Groups ← DIV(30, 4)
Section B: Match the Pairs
Q1
DIV(10, 3) → Returns 3, the whole-number part of 10 divided by 3, with the remainder discarded
Q2
DIV(17, 5) → Returns 3, because 5 goes into 17 three whole times
Q3
Find how many whole 60-minute hours are in a number of minutes stored in Minutes → Hours ← DIV(Minutes, 60)
Q4
Find how many full packs of 6 can be made from Total eggs → FullPacks ← DIV(Total, 6)
Q5
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.
Q6
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).
Section C: Definitions
Q1
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.
Section D: Fill in the Blanks
Q1
OUTPUT DIV(10, 3)
Q2
OUTPUT DIV(17, 5) // gives 3
Q3
INPUT Minutes Hours ← DIV(Minutes, 60) OUTPUT Hours
Q4
DECLARE Packs : INTEGER Packs ← DIV(50, 12) OUTPUT Packs
Q5
Students ← 95 Rows ← DIV(Students, 10) OUTPUT Rows // shows 9
Section E: Spot the Error
Q1
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.
Q2
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.
Q3
C — In Cambridge pseudocode DIV is a function, not an infix operator. It must be written with brackets as DIV(Sweets, 4).
Q4
A — DIV returns a whole number (3), so the variable that stores it should be declared as INTEGER, not STRING.
Q5
C — DIV needs two arguments: the number being divided and the divisor. It should be DIV(Pupils, Seats).