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 Line(5) | AThe length 5 is fixed inside the procedure and there is no parameter, so every call draws the same line. The procedure cannot be reused for different lengths. | |
| 2PROCEDURE Line(Length : INTEGER) | BCALL Line(4) CALL Line(4) CALL Line(4) | |
| 3Reuse with different parameters: the same procedure draws a short line and then a long line | CThe same loop is copied out twice instead of being written once in a procedure and called twice. This wastes typing and makes copy errors more likely. | |
| 4A subroutine written once is called from many places, so the program is shorter than repeating the loop | DDefines the reusable code once, with a parameter so each call can use a different value | |
| 5FOR i ← 1 TO 5 OUTPUT "*" NEXT i FOR i ← 1 TO 5 OUTPUT "*" NEXT i | ECALL Line(3) CALL Line(10) | |
| 6PROCEDURE Line() FOR i ← 1 TO 5 OUTPUT "*" NEXT i ENDPROCEDURE | FCalls the Line procedure with the value 5, reusing code that was written once instead of repeating a loop |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
CALL Line(5) — Calls the Line procedure written once, so the same code is reused many times with different parameters instead of being repeated in the program.CALL Line(5)CALL Line(5)
CALL Line(8)
CALL Line(3)Width ← 7
CALL Line(Width)PROCEDURE Line(Count : INTEGER)
FOR Index ← 1 TO Count
OUTPUT "*"NEXT Index
ENDPROCEDURE
CALL Line(6)