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 ShowDouble(4) | ACALL Square(2)\nCALL Square(5) | |
| 2CALL Greet("Sam")\nOUTPUT "Bye" | BThe parameter must be given the value passed in the call (3), not 0 or a blank | |
| 3Two calls with different values need two sets of rows in the trace table: Num is 2 for the first call, then 5 for the second | CIn the trace table, the parameter Num is given the value 4 before any statement in the procedure runs | |
| 4A local variable is reset in each call, so Total starts again from 0 every time the procedure runs | DA local variable does not keep its value between calls; it starts fresh each time the procedure is called | |
| 5CALL Show(3) traced with Num = 0 in the first row | EPROCEDURE Add(N : INTEGER)\n DECLARE Total : INTEGER\n Total ← 0 + N | |
| 6Trace of 2nd call: Count = 5 carried over from 1st call | FThe greeting is output first, then control returns to the main program and Bye is output second |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace table — A table used to trace a call: record the value given to each parameter, follow the procedure's statements, then return to the next line of the main program.CALL Show(5)
OUTPUT "Back in main"PROCEDURE Double(Num : INTEGER)
OUTPUT Num * 2
ENDPROCEDUREPROCEDURE Show(Num : INTEGER)
OUTPUT Num
ENDPROCEDUREPROCEDURE AddTen(Num : INTEGER)
Sum ← Num + 10
OUTPUT SumPROCEDURE Show(Num : INTEGER)
OUTPUT Num
ENDPROCEDURE