ROUND: rounding to decimal places

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

ROUND: rounding to decimal places

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does ROUND(3.14159, 2) return?
A 3.14
B 3.15
2. In ROUND(7.8261, 3), what does the second value, 3, tell the routine?
A How many times to repeat the rounding
B How many decimal places to round to
3. What does ROUND(8.67, 0) return?
A 9
B 8.7
4. Which call rounds the REAL variable Price to 1 decimal place?
A ROUND(Price, 1)
B ROUND(1, Price)
5. Which is a valid use of ROUND with an expression as the value?
A Total ← ROUND(Cost * 1.2)
B Total ← ROUND(Cost * 1.2, 2)

Match the Pairs

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

Left columnRight column
1ROUND(3.14159, 2) AReturns 3.14, the value rounded to 2 decimal places
2ROUND(7.6, 0) BThe arguments are in the wrong order. The value comes first and the INTEGER places comes second, so it should be ROUND(8.567, 2).
3The value given to ROUND can be an identifier holding a REAL number COUTPUT ROUND(Total / 3, 2)
4The value given to ROUND can be an expression, which is worked out first and then rounded DThe places argument is missing. ROUND needs two arguments: the value and the number of decimal places, e.g. ROUND(8.567, 2).
5Answer ← ROUND(8.567) EResult ← ROUND(Price, 1)
6Answer ← ROUND(2, 8.567) FReturns 8, a whole number, because places is 0

Definitions

ROUND(value, places)

Fill in the Blanks

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

1.
OUTPUT _____(3.14159, 2)
2.
OUTPUT ROUND(3.14159, _)
3.
Total ← 7.6 Whole ← ROUND(Total, _)
4.
Average ← ROUND(_____________, 1)
5.
Area ← 3.14159 * Radius * Radius OUTPUT ROUND(____, 2)

Spot the Error

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

Question 1
A Result ← ROUND(3.14159; 2)
B OUTPUT Result
C OUTPUT ROUND(Result, 1)
Question 2
A DECLARE Mark : REAL
B Mark ← 7.6543
C Mark ← ROUND(Mark)
D OUTPUT Mark
Question 3
A DECLARE Total : REAL
B Total ← 12.3456
C Rounded ← ROUND(2, Total)
D OUTPUT Rounded
Question 4
A INPUT Cost
B Cost ← ROUND(Cost * 1.2, 2
C OUTPUT Cost
Question 5
A DECLARE Avg : REAL
B DECLARE Total : INTEGER
C Total ← 25
D Avg ← ROUND(Total / 3, 1.5)
E OUTPUT Avg

Answer Key

ROUND: rounding to decimal places
Section A: Quick Questions
Q1
A — 3.14
Q2
B — How many decimal places to round to
Q3
A — 9
Q4
A — ROUND(Price, 1)
Q5
B — Total ← ROUND(Cost * 1.2, 2)
Section B: Match the Pairs
Q1
ROUND(3.14159, 2) → Returns 3.14, the value rounded to 2 decimal places
Q2
ROUND(7.6, 0) → Returns 8, a whole number, because places is 0
Q3
The value given to ROUND can be an identifier holding a REAL number → Result ← ROUND(Price, 1)
Q4
The value given to ROUND can be an expression, which is worked out first and then rounded → OUTPUT ROUND(Total / 3, 2)
Q5
Answer ← ROUND(8.567) → The places argument is missing. ROUND needs two arguments: the value and the number of decimal places, e.g. ROUND(8.567, 2).
Q6
Answer ← ROUND(2, 8.567) → The arguments are in the wrong order. The value comes first and the INTEGER places comes second, so it should be ROUND(8.567, 2).
Section C: Definitions
Q1
ROUND(value, places) — Library routine that returns value rounded to the given number of decimal places. ROUND(3.14159, 2) gives 3.14. If places is 0, the result is a whole number.
Section D: Fill in the Blanks
Q1
OUTPUT ROUND(3.14159, 2)
Q2
OUTPUT ROUND(3.14159, 2)
Q3
Total ← 7.6 Whole ← ROUND(Total, 0)
Q4
Average ← ROUND(Total / Count, 1)
Q5
Area ← 3.14159 * Radius * Radius OUTPUT ROUND(Area, 2)
Section E: Spot the Error
Q1
A — The arguments of ROUND must be separated by a comma, not a semicolon. It should be ROUND(3.14159, 2).
Q2
C — ROUND needs two arguments: the value and the number of decimal places. It should be ROUND(Mark, 2).
Q3
C — The arguments are in the wrong order. The value comes first and the places second, so it should be ROUND(Total, 2).
Q4
B — The closing bracket is missing. The call must end with ), so it should be ROUND(Cost * 1.2, 2).
Q5
D — The places argument must be an INTEGER because it counts decimal places. 1.5 is a REAL, so it should be ROUND(Total / 3, 1).