Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1RETURN Number MOD 2 = 0 | AOUTPUT ROUND(CalculateTotal(Price), 2) | |
| 2RETURN ROUND(Price * 1.1, 2) | BFUNCTION RollDie() RETURNS INTEGER RETURN ROUND(RANDOM() * 5, 0) + 1 ENDFUNCTION | |
| 3A function called RollDie uses the RANDOM library routine and returns a whole number from 1 to 6 | CThe result of ROUND is not returned. The function must use RETURN so the rounded value is passed back to the caller. | |
| 4A user-defined function is used beside a library routine in one statement, by passing the function's result into ROUND | DDIV is used instead of MOD. DIV gives the whole-number quotient, not the remainder, so the test does not check whether the number is even. | |
| 5FUNCTION IsEven(Number : INTEGER) RETURNS BOOLEAN RETURN Number DIV 2 = 0 ENDFUNCTION | EInside IsEven, this uses MOD to find the remainder after dividing by 2 and returns TRUE when the remainder is 0 | |
| 6FUNCTION RoundPrice(Price : REAL) RETURNS REAL ROUND(Price, 2) ENDFUNCTION | FInside a function, this works out the price plus 10 percent and returns it rounded to 2 decimal places |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
RETURN ROUND(Price, 2) — Your own subroutine can call a library routine such as ROUND, MOD, DIV or RANDOM in its statements and use the value it gives back, for example in a RETURN.FUNCTION IsEven(N : INTEGER) RETURNS BOOLEAN
RETURN N MOD 2 = 0
ENDFUNCTIONFUNCTION RollDie() RETURNS INTEGER
RETURN ROUND(RANDOM() * 5, 0) + 1
ENDFUNCTIONFUNCTION Tidy(Price : REAL) RETURNS REAL
RETURN ROUND(Price, 2)
ENDFUNCTIONResult ← ROUND(AddTax(Price), 2)
OUTPUT ResultFUNCTION Tens(N : INTEGER) RETURNS INTEGER
RETURN N DIV 10
ENDFUNCTION