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 Total : INTEGER | AFUNCTION Double(N : INTEGER) RETURNS INTEGER DECLARE Result : INTEGER Result <- N * 2 RETURN Result ENDFUNCTION | |
| 2PROCEDURE ShowArea(Width : INTEGER) | BCount is declared outside the procedure in the main program, so it is not a local variable of Greet. DECLARE must be inside the procedure body. | |
| 3A local variable is declared inside the body of a function, before it is used | CWidth is a parameter, which is also a local variable that can only be used inside ShowArea | |
| 4A local variable is not available in the main program after the subroutine has finished | DCreates a local variable called Total inside a subroutine, which can only be used in that subroutine | |
| 5PROCEDURE Greet() OUTPUT Count ENDPROCEDURE DECLARE Count : INTEGER | ECALL ShowArea(5) OUTPUT Length | |
| 6CALL Calculate() OUTPUT Length | FLength is a local variable declared inside Calculate, so the main program cannot use it after the call. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
DECLARE — Creates a local variable inside a procedure or function, e.g. DECLARE Length : INTEGER. It exists only while the subroutine runs and cannot be used in the main program.PROCEDURE ShowArea()
DECLARE Length : INTEGER
ENDPROCEDUREPROCEDURE ShowPrice()
DECLARE Price : REAL
Price ← 2.5PROCEDURE ShowLength()
DECLARE Length : INTEGER
Length ← 5PROCEDURE Show(Width : INTEGER)
OUTPUT Width * 2
ENDPROCEDUREPROCEDURE Show()
DECLARE Mark : INTEGER
Mark ← 80