MOD: remainder (8.1c)

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

MOD: remainder (8.1c)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does MOD(10, 3) return?
A 1
B 3
2. Which statement describes MOD(a, b)?
A It returns the whole-number part of a divided by b
B It returns the remainder left when a is divided by b
3. What does MOD(12, 4) return?
A 3
B 0
4. A student wants the leftover minutes after converting 130 minutes into hours. Which expression is correct?
A MOD(130, 60)
B MOD(60, 130)
5. If MOD(a, b) gives 0, what do we know?
A b divides a exactly
B a is smaller than b

Match the Pairs

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

Left columnRight column
1MOD(10, 3) AGives 0, because 4 divides 12 exactly with nothing left over
2MOD(12, 4) BGives 1, because 3 goes into 10 three times (9) and 1 is left over
3Find the leftover minutes after taking 130 minutes and removing whole hours CIF MOD(Number, 2) = 0 THEN
4Check whether a whole number is even by testing if the remainder after dividing by 2 is 0 DMOD needs two arguments, a and b. Only one was given, so it cannot work out a remainder. It should be MOD(10, 3).
5OUTPUT MOD(10) Eleftover ← MOD(130, 60)
6OUTPUT MOD(3, 10) FThe arguments are in the wrong order. To get the remainder of 10 divided by 3 it should be MOD(10, 3), which gives 1. MOD(3, 10) gives 3.

Definitions

MOD(a, b)

Fill in the Blanks

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

1.
OUTPUT ___(10, 3)
2.
Minutes ← MOD(130, __)
3.
LeftoverMinutes ← MOD(130, 60) OUTPUT _______________
4.
IF MOD(Number, 2) = _ THEN OUTPUT "Even" ENDIF
5.
Hours ← 130 DIV 60 Minutes ← ___(130, 60) OUTPUT Hours, Minutes

Spot the Error

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

Question 1
A DECLARE TotalMins : INTEGER
B TotalMins ← 130
C DECLARE Left : INTEGER
D Left ← MOD(60, TotalMins)
E OUTPUT Left
Question 2
A Num ← 10
B Rem ← MOD(Num 3)
C OUTPUT Rem
Question 3
A DECLARE Number : INTEGER
B Number ← 12
C IF MOD(Number, 2) = 1 THEN
D OUTPUT "Even"
E ENDIF
Question 4
A TotalMins ← 130
B Mins ← TotalMins DIV 60
C OUTPUT Mins
Question 5
A A ← 17
B B ← 5
C R = MOD(A, B)
D OUTPUT R

Answer Key

MOD: remainder (8.1c)
Section A: Quick Questions
Q1
A — 1
Q2
B — It returns the remainder left when a is divided by b
Q3
B — 0
Q4
A — MOD(130, 60)
Q5
A — b divides a exactly
Section B: Match the Pairs
Q1
MOD(10, 3) → Gives 1, because 3 goes into 10 three times (9) and 1 is left over
Q2
MOD(12, 4) → Gives 0, because 4 divides 12 exactly with nothing left over
Q3
Find the leftover minutes after taking 130 minutes and removing whole hours → leftover ← MOD(130, 60)
Q4
Check whether a whole number is even by testing if the remainder after dividing by 2 is 0 → IF MOD(Number, 2) = 0 THEN
Q5
OUTPUT MOD(10) → MOD needs two arguments, a and b. Only one was given, so it cannot work out a remainder. It should be MOD(10, 3).
Q6
OUTPUT MOD(3, 10) → The arguments are in the wrong order. To get the remainder of 10 divided by 3 it should be MOD(10, 3), which gives 1. MOD(3, 10) gives 3.
Section C: Definitions
Q1
MOD(a, b) — Returns the remainder left when a is divided by b. MOD(10, 3) is 1. The result is 0 when b divides a exactly. Example: MOD(130, 60) gives the 10 leftover minutes.
Section D: Fill in the Blanks
Q1
OUTPUT MOD(10, 3)
Q2
Minutes ← MOD(130, 60)
Q3
LeftoverMinutes ← MOD(130, 60) OUTPUT LeftoverMinutes
Q4
IF MOD(Number, 2) = 0 THEN OUTPUT "Even" ENDIF
Q5
Hours ← 130 DIV 60 Minutes ← MOD(130, 60) OUTPUT Hours, Minutes
Section E: Spot the Error
Q1
D — The arguments are the wrong way round. MOD(a, b) is the remainder when a is divided by b, so the total minutes must come first: MOD(TotalMins, 60) gives the 10 leftover minutes.
Q2
B — The two arguments of MOD must be separated by a comma. It should be MOD(Num, 3), which gives 1.
Q3
C — An even number divides exactly by 2, so the remainder is 0, not 1. The condition should be MOD(Number, 2) = 0.
Q4
B — DIV gives the whole number of hours (2), not the leftover minutes. The leftover minutes need the remainder, so use MOD(TotalMins, 60), which gives 10.
Q5
C — Assignment in IGCSE pseudocode uses the ← arrow, not =. It should be R ← MOD(A, B), which stores 2.