Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Matching argument values to parameter types and order worksheet is part of the IGCSE Computer Science 0478 — 8.1c Procedures and Functions journey. Print it as a booklet?
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 | |
|---|---|---|
| 1CALL ShowTotal("five", 3) // parameter 1 is INTEGER | AError: the STRING "five" is passed to an INTEGER parameter, so the data type does not match. | |
| 2CALL Rectangle(5) // needs width, height | BToo many values: three values are given for two parameters. Remove one value, for example CALL SetScore(10, 20). | |
| 3Values go to parameters in order, so the first value is given to the first parameter. For PROCEDURE Greet(Name : STRING, Age : INTEGER) this call is correct. | CError: too few values, because the procedure has two parameters but the call gives only one. | |
| 4A REAL value such as 7.5 can only be passed to a parameter declared as REAL, so the parameter must be REAL, as in PROCEDURE ShowPrice(Price : REAL). | DThe values are in the wrong order: 15 is passed to the STRING parameter and "Sam" to the INTEGER parameter. Swap them to CALL Greet("Sam", 15). | |
| 5CALL Greet(15, "Sam") // Greet(Name : STRING, Age : INTEGER) | ECALL Greet("Sam", 15) | |
| 6CALL SetScore(10, 20, 30) // SetScore(A : INTEGER, B : INTEGER) | FCALL ShowPrice(7.5) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
CALL Name(value1, value2) — Each value in a call must match its parameter in number, order and data type, so a STRING cannot go to an INTEGER parameter and values cannot be swapped or left out.PROCEDURE Repeat(Times : INTEGER)
CALL Repeat(5)PROCEDURE Area(Len : INTEGER, Wide : REAL)
CALL Area(5, 2.5)PROCEDURE Show(Name : STRING, Age : INTEGER)
CALL Show("Ann", 14)FUNCTION Cost(Qty : INTEGER, Price : REAL)
Total ← Cost(2, 1.5)PROCEDURE Score(Mark : INTEGER, Team : STRING
)
CALL Score(80, "Red")