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 CalcArea(L : INTEGER, W : INTEGER) RETURNS INTEGER | AA procedure cannot return a value. The task produces one value the program needs, so it should be a FUNCTION with RETURNS and ENDFUNCTION. | |
| 2PROCEDURE ShowMenu() | BCALL ShowMenu() | |
| 3A function returns a value to the program, so the result can be stored in a variable. | CUse a function because the task produces one value, the area, that the program needs. | |
| 4A procedure only carries out actions such as OUTPUT, so it is run with its own CALL statement. | DUse a procedure because the task only does something, such as displaying a menu, and gives no value back. | |
| 5PROCEDURE CalcArea(L, W) RETURN L * W ENDPROCEDURE | EArea ← CalcArea(5, 3) | |
| 6FUNCTION ShowMenu() OUTPUT "1. Play" ENDFUNCTION | FDisplaying a menu only does something and returns no value, so it should be a PROCEDURE and not a FUNCTION. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FUNCTION — Use a FUNCTION when a task produces one value the program needs, such as an area; use a PROCEDURE when it only does something, such as OUTPUT a menu.PROCEDURE ShowMenu()
OUTPUT "1. Play"
ENDPROCEDUREFUNCTION Area(L : INTEGER) RETURNS INTEGER
RETURN L * L
ENDFUNCTIONFUNCTION Area(L, W) RETURNS INTEGER
RETURN L * W
ENDFUNCTIONCALL ShowMenu()
area ← Area(4, 5)area ← Area(3, 6)
OUTPUT area