Arithmetic operators in Cambridge pseudocode

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

Arithmetic operators in Cambridge pseudocode

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What is the value of 17 DIV 5?
A 2
B 3
2. What is the value of 17 MOD 5?
A 3
B 2
3. Which result does 7 / 2 give in Cambridge pseudocode?
A 3.5
B 3
4. Which expression gives the whole-number quotient of 20 divided by 6?
A 20 DIV 6
B 20 MOD 6
5. What is the value of 2 + 3 * 4?
A 14
B 20

Match the Pairs

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

Left columnRight column
117 DIV 5 ADIV gives the quotient, not the remainder. To test for even, use Number MOD 2 = 0.
217 MOD 5 BResult ← 7 / 2
3The / operator gives a real result, so dividing 7 by 2 gives 3.5 C/ gives the real result 3.4, not the whole number 3. Use 17 DIV 5 to get the whole-number quotient.
4Brackets set the order, so the addition is done before the multiplication and the answer is 20 DTotal ← (2 + 3) * 4
5Pages ← 17 / 5 OUTPUT Pages (meant to find whole pages, expecting 3) EGives the remainder after dividing, so the result is 2
6IF Number DIV 2 = 0 THEN (meant to test for an even number) FGives the whole-number quotient, so the result is 3

Definitions

+ - * / DIV MOD

Fill in the Blanks

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

1.
Quotient ← 17 ___ 5
2.
Remainder ← 17 ___ 5
3.
Average ← Total _ Count
4.
Hours ← TotalMins ___ 60 Mins ← TotalMins MOD 60
5.
Mean ← _Score1 + Score2) / 2

Spot the Error

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

Question 1
A DECLARE Rem : INTEGER
B Num ← 17
C Rem ← Num DIV 5
D OUTPUT Rem
Question 2
A Minutes ← 135
B Hours ← Minutes MOD 60
C Left ← Minutes MOD 60
D OUTPUT Hours, Left
Question 3
A INPUT Num
B IF Num DIV 2 = 0 THEN
C OUTPUT "Even"
D ENDIF
Question 4
A A ← 80
B B ← 70
C C ← 90
D Avg ← A + B + C / 3
E OUTPUT Avg
Question 5
A Price ← 4.50
B Total ← Price x 3
C OUTPUT Total

Answer Key

Arithmetic operators in Cambridge pseudocode
Section A: Quick Questions
Q1
B — 3
Q2
B — 2
Q3
A — 3.5
Q4
A — 20 DIV 6
Q5
A — 14
Section B: Match the Pairs
Q1
17 DIV 5 → Gives the whole-number quotient, so the result is 3
Q2
17 MOD 5 → Gives the remainder after dividing, so the result is 2
Q3
The / operator gives a real result, so dividing 7 by 2 gives 3.5 → Result ← 7 / 2
Q4
Brackets set the order, so the addition is done before the multiplication and the answer is 20 → Total ← (2 + 3) * 4
Q5
Pages ← 17 / 5 OUTPUT Pages (meant to find whole pages, expecting 3) → / gives the real result 3.4, not the whole number 3. Use 17 DIV 5 to get the whole-number quotient.
Q6
IF Number DIV 2 = 0 THEN (meant to test for an even number) → DIV gives the quotient, not the remainder. To test for even, use Number MOD 2 = 0.
Section C: Definitions
Q1
+ - * / DIV MOD — Arithmetic operators: + - * / calculate with numbers, and / gives a real result. DIV gives the whole-number quotient and MOD the remainder, so 17 DIV 5 is 3 and 17 MOD 5 is 2.
Section D: Fill in the Blanks
Q1
Quotient ← 17 DIV 5
Q2
Remainder ← 17 MOD 5
Q3
Average ← Total / Count
Q4
Hours ← TotalMins DIV 60 Mins ← TotalMins MOD 60
Q5
Mean ← (Score1 + Score2) / 2
Section E: Spot the Error
Q1
C — DIV gives the whole-number quotient (3). The remainder is found with MOD, so the line should be Rem ← Num MOD 5, which gives 2.
Q2
B — MOD gives the remainder (15), not the number of whole hours. Whole hours need DIV: Hours ← Minutes DIV 60, which gives 2.
Q3
B — To test for an even number, check that the remainder after dividing by 2 is 0. That needs MOD, not DIV: IF Num MOD 2 = 0 THEN.
Q4
D — Division is done before addition, so only C is divided by 3. Brackets are needed to add first: Avg ← (A + B + C) / 3.
Q5
B — The letter x is not a multiplication operator in Cambridge pseudocode. Multiplication is *, so it should be Total ← Price * 3.