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 | |
|---|---|---|
| 1FUNCTION Double(N : INTEGER) RETURNS INTEGER | AThe header has no RETURNS data type, so the type of the value that comes back is not stated. It should be RETURNS INTEGER. | |
| 2RETURN N * 2 | BStarts a function called Double that takes an integer and sends back one INTEGER value | |
| 3A function call can be used as part of an expression because it gives back one value | CSends one value back to the place where the function was called | |
| 4The returned value has a data type that is declared in the function header | DFUNCTION IsAdult(Age : INTEGER) RETURNS BOOLEAN | |
| 5FUNCTION Double(N : INTEGER) RETURN N * 2 ENDFUNCTION | EAnswer ← Double(4) + 1 | |
| 6FUNCTION Double(N : INTEGER) RETURNS INTEGER OUTPUT N * 2 ENDFUNCTION | FThe function uses OUTPUT instead of RETURN, so no value comes back to the call. It should be RETURN N * 2. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FUNCTION — A named subroutine that returns a single value to the place where it is called, so the call can be used inside an expression, such as x ← Total(2, 3).FUNCTION Twice(N : INTEGER) RETURNS INTEGER
RETURN N * 2
ENDFUNCTIONFUNCTION Twice(N : INTEGER) RETURNS INTEGER
RETURN N * 2
ENDFUNCTIONFUNCTION Twice(N : INTEGER) RETURNS INTEGER
RETURN N * 2
ENDFUNCTIONFUNCTION IsBig(N : INTEGER) RETURNS BOOLEAN
RETURN N > 100
ENDFUNCTIONx ← Total(2, 3)
OUTPUT x