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 | |
|---|---|---|
| 1CALL SumSquare(2, 3) | ACorrect use of a function call inside an expression. The returned value is used in the calculation and stored in Total. | |
| 2Total ← AddFive(4) + 1 | BWrong when SumSquare is a function. CALL is only for procedures, so a function must be used in an expression, in OUTPUT or stored in a variable. | |
| 3A function call on a line by itself throws away the returned value, so the result is lost. | CThe ENDFUNCTION statement is missing. Every function must finish with ENDFUNCTION, and every procedure with ENDPROCEDURE. | |
| 4A procedure does not return a value, so it must be run with CALL and not used inside an expression. | DShowTotal is a procedure, so it returns no value. It cannot be used in an expression. Use CALL ShowTotal(5) on its own, or make it a function. | |
| 5Answer ← ShowTotal(5) + 1 | ECALL ShowTotal(5) | |
| 6FUNCTION Double(N : INTEGER) RETURNS INTEGER RETURN N * 2 | FSumSquare(2, 3) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
CALL SumSquare(2, 3) — A common error when SumSquare is a function. CALL is only for procedures. A function returns a value, so use it in an expression, in OUTPUT, or store it in a variable.CALL ShowScore(5)Total ← SumSquare(2, 3)OUTPUT SumSquare(2, 3)PROCEDURE ShowScore(Score : INTEGER)
OUTPUT Score
ENDPROCEDUREFUNCTION Twice(N : INTEGER) RETURNS INTEGER
RETURN N * 2
ENDFUNCTION