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 | |
|---|---|---|
| 1OUTPUT SumSquare(10, 20) + 1 | AThe student added the arguments and ignored the function's statements. They must follow the statements to RETURN: 10*10 + 20*20 = 500. | |
| 2IF IsEven(7) THEN | B7 MOD 2 is 1, so the function returns FALSE. The call is replaced by FALSE and the THEN block is skipped. | |
| 3A function result stored in a variable: the call is replaced by the returned value, which is then assigned to the variable. | CThe call was replaced by 13 but the rest of the expression was not finished. 13 + 1 must be evaluated, so 14 is output. | |
| 4Tracing a function inside OUTPUT: replace the call with the returned value, then output that value. | DOUTPUT SumSquare(3, 4) | |
| 5SumSquare(10, 20) is replaced by 30 | ETotal ← SumSquare(10, 20) | |
| 6OUTPUT SumSquare(2, 3) + 1 shows 13 | FThe call returns 500 (100 + 400). The call is replaced by 500 and the expression is finished, so 501 is output. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
SumSquare(10, 20) — Tracing a call: follow the function's statements to RETURN, then replace the call with the returned value (here 500) and finish evaluating the expression.Total ← SumSquare(10, 20)
OUTPUT TotalFUNCTION SumSquare(A, B) RETURNS INTEGER
RETURN A * A + B * B
ENDFUNCTIONIF IsEven(8) = TRUE THEN
OUTPUT "Even"
ENDIFTotal ← SumSquare(10, 20) + 1
// the call is replaced by 500
// so Total is 501// SumSquare returns A * A + B * B
OUTPUT SumSquare(10, 20)
// the call is replaced by 500