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 | |
|---|---|---|
| 1PROCEDURE ShowMenu() OUTPUT "1. Play" ENDPROCEDURE CALL ShowMenu() | APROCEDURE Greet() OUTPUT "Hi" ENDPROCEDURE CALL Greet() | |
| 2FUNCTION Double(n : INTEGER) RETURNS INTEGER RETURN n * 2 ENDFUNCTION OUTPUT Double(4) | BFUNCTION Square(n : INTEGER) RETURNS INTEGER RETURN n * n ENDFUNCTION result <- Square(5) | |
| 3Definitions come first in a short program, then the main program with the calls comes after them. | CThe main program statement that calls the function is written before the function definition. The function should be defined first. | |
| 4The main program holds the calls, so a function call such as one in an assignment goes after the definition. | DThe procedure is defined first. The CALL line comes after it, in the main program. | |
| 5CALL ShowMenu() PROCEDURE ShowMenu() OUTPUT "1. Play" ENDPROCEDURE | EThe function is defined at the start. The main program after it uses the function call. | |
| 6OUTPUT Double(4) FUNCTION Double(n : INTEGER) RETURNS INTEGER RETURN n * 2 ENDFUNCTION | FThe CALL is placed before the procedure is defined. The definition must come first, then the main program with the CALL. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Define then call — Write procedures and functions at the start of the code, before the main program. The main program comes after and holds the CALL statements and function calls that use them.PROCEDURE Hello()
OUTPUT "Hi"
ENDPROCEDUREENDPROCEDURE
// Main program
CALL Hello()FUNCTION Double(N : INTEGER) RETURNS INTEGER
RETURN N * 2
ENDFUNCTIONENDFUNCTION
// Main program
Answer ← Double(5)PROCEDURE Hello()
ENDPROCEDURE
CALL Hello()