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 | |
|---|---|---|
| 1DECLARE Score : INTEGER | AScore is declared after the procedure, not at the start of the program. The global DECLARE should come first, before the subroutines and the main program use it. | |
| 2Score ← Score + 10 | BFUNCTION DoubleScore() RETURNS INTEGER RETURN Score * 2 ENDFUNCTION | |
| 3A global variable is available everywhere, so a function can use it without it being passed in as a parameter | CCALL AddPoints() OUTPUT Score | |
| 4A global variable exists for the whole program, so the main program can output it after a procedure has changed it | DLives is declared inside the procedure, so it is a local variable. The main program cannot use it. To make it global, declare it at the start of the program, outside the procedure. | |
| 5PROCEDURE SetUp() DECLARE Lives : INTEGER Lives ← 3 ENDPROCEDURE OUTPUT Lives | EWhen written at the start of the program, outside every subroutine, this creates a global variable that the whole program can use | |
| 6PROCEDURE AddPoints() Score ← Score + 5 ENDPROCEDURE DECLARE Score : INTEGER | FInside a procedure, this changes the global variable Score, and the new value is still there after the procedure ends |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
global variable — A variable declared outside every subroutine, so the main program and any procedure or function can use and change it. It exists for the whole program.DECLARE Score : INTEGERDECLARE Score : INTEGER
Score ← 0PROCEDURE AddPoint()
Score ← Score + 1
ENDPROCEDUREFUNCTION DoubleScore() RETURNS INTEGER
RETURN Score * 2
ENDFUNCTIONDECLARE Score : INTEGER
Score ← 0
CALL AddPoint()