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 | |
|---|---|---|
| 1// Calculates the area of a rectangle | Atotal ← total + 1 // add one to the count | |
| 2// width and height are both INTEGER | BA comment that states the parameters of the subroutine below it | |
| 3A comment is written on the line before the procedure and explains what it does | CThe comment has no // at the start, so the computer treats it as code and reports an error. It should be // Calculates the area of a rectangle. | |
| 4A short end-of-line comment can explain one line of code, and the computer ignores it | D// Displays a greeting for the name given PROCEDURE Greet(name : STRING) | |
| 5Calculates the area of a rectangle FUNCTION Area(w : INTEGER, h : INTEGER) RETURNS INTEGER | EThe comment is placed after the procedure header instead of on the line before it. It should be written above the PROCEDURE line. | |
| 6PROCEDURE ShowScore(score : INTEGER) // Displays the score | FA comment placed on the line before a function that states its purpose |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
// — Starts a comment. Put one on the line before a procedure or function to say what it does and what its parameters are. The computer ignores comments.// Shows a welcome message. No parameters.
PROCEDURE ShowMessage()
OUTPUT "Welcome"// Returns N multiplied by 2
FUNCTION Double(N : INTEGER) RETURNS INTEGER
RETURN N * 2Total ← Price * Qty // cost of all items// Shows Name on the screen. Parameter: Name
PROCEDURE ShowName(Name : STRING)
OUTPUT Name// Purpose: add tax to Price
FUNCTION AddTax(Price : REAL) RETURNS REAL
RETURN Price * 1.2