Arithmetic Operators in Pseudocode

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

Arithmetic Operators in Pseudocode

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which operator is used for multiplication in VCAA pseudocode?
A * — for example: area <- length * width
B x — for example: area <- length x width
2. What does the MOD operator return in pseudocode?
A The whole number result of division
B The remainder after integer division
3. What does total DIV 4 return when total is 10?
A 2.5 — the exact decimal result
B 2 — the whole number part of 10 / 4
4. Which correctly subtracts cost from revenue in pseudocode?
A profit <- revenue - cost
B profit <- revenue -- cost
5. What does 15 MOD 4 evaluate to in pseudocode?
A 3 — the remainder when 15 is divided by 4
B 3.75 — the decimal result of 15 divided by 4

Match the Pairs

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

Left columnRight column
1area <- length * width AWrong — x is not a valid pseudocode operator. The multiplication operator is the asterisk *. The correct form is `area <- length * width`
2remainder <- total MOD 7 BDivides total by 7 and stores only the remainder in the variable remainder — for example if total is 22 the result is 1
3DIV returns the whole number part of a division, discarding any remainder Cquotient <- 17 DIV 5
4The + operator adds two values and the - operator subtracts one value from another Dtotal <- a + b profit <- revenue - cost
5area <- length x width EWrong — the caret ^ is not a standard VCAA pseudocode operator. To square a value, multiply it by itself: `result <- a * a`
6result <- a ^ 2 FMultiplies length by width using the * operator and stores the result in area

Definitions

MOD

Fill in the Blanks

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

1.
total <- price _ quantity
2.
average <- (a + b) _ 2
3.
remainder <- total ___ 7
4.
quotient <- total ___ 4
5.
profit <- revenue _ cost

Spot the Error

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

Question 1
A Algorithm: compute area
B input length, width
C area <- length x width
D print area
Question 2
A Algorithm: find average
B input a, b, c
C total <- a + b + c
D average <- total \ 3
E print average
Question 3
A Algorithm: get remainder
B input n
C remainder <- n MOD 5
D print remainder
Question 4
A Algorithm: integer divide
B input total
C result <- total DIV 4
D print results
Question 5
A Algorithm: calculate tax
B input income
C tax <- income * 0.2
D net <- income - tax
E print net

Answer Key

Arithmetic Operators in Pseudocode
Section A: Quick Questions
Q1
A — * — for example: area <- length * width
Q2
B — The remainder after integer division
Q3
B — 2 — the whole number part of 10 / 4
Q4
A — profit <- revenue - cost
Q5
A — 3 — the remainder when 15 is divided by 4
Section B: Match the Pairs
Q1
area <- length * width → Multiplies length by width using the * operator and stores the result in area
Q2
remainder <- total MOD 7 → Divides total by 7 and stores only the remainder in the variable remainder — for example if total is 22 the result is 1
Q3
DIV returns the whole number part of a division, discarding any remainder → quotient <- 17 DIV 5
Q4
The + operator adds two values and the - operator subtracts one value from another → total <- a + b profit <- revenue - cost
Q5
area <- length x width → Wrong — x is not a valid pseudocode operator. The multiplication operator is the asterisk *. The correct form is `area <- length * width`
Q6
result <- a ^ 2 → Wrong — the caret ^ is not a standard VCAA pseudocode operator. To square a value, multiply it by itself: `result <- a * a`
Section C: Definitions
Q1
MOD — The pseudocode operator that returns the remainder after integer division. Example: 10 MOD 3 gives 1 because 10 divided by 3 is 3 remainder 1
Section D: Fill in the Blanks
Q1
total <- price * quantity
Q2
average <- (a + b) / 2
Q3
remainder <- total MOD 7
Q4
quotient <- total DIV 4
Q5
profit <- revenue - cost
Section E: Spot the Error
Q1
C — `length x width` uses the letter x as a multiplication symbol, which is not valid in pseudocode. The correct operator for multiplication is the asterisk *. The line should read `area <- length * width`. Line 2 is wrong.
Q2
D — The backslash \ is not a valid pseudocode operator. For division the correct operator is the forward slash /. The line should read `average <- total / 3`. Line 3 is wrong.
Q3
A — The algorithm header is missing its colon. The correct form is `Algorithm: get remainder` with a colon after the keyword Algorithm. Line 0 is wrong.
Q4
D — `print results` references a variable called `results` but the variable assigned on line 2 is called `result`. Variable names must match exactly. The line should read `print result`. Line 3 is wrong.
Q5
C — `income * 0.2` uses a decimal multiplier not typical in VCAA pseudocode which conventionally uses integer or variable operands. The more standard form expresses 20% as `tax <- income / 5`. Line 2 is wrong.