Calling a procedure with a value

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Calling a procedure with a value

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly calls the procedure Line and passes the value 60?
A CALL Line(60)
B Line 60
2. Which line passes the variable MySize into the procedure Line?
A CALL Line MySize
B CALL Line(MySize)
3. PROCEDURE Line(Size : INTEGER) is called with CALL Line(60). What happens to the parameter Size?
A Size takes the value 60 inside the procedure
B Size stays empty and 60 is ignored
4. A program runs CALL Line(20) and later CALL Line(80). What is the result?
A The same procedure runs, but with different results because the values differ
B Both calls give exactly the same result because it is the same procedure
5. After MySize ← 45, the line CALL Line(MySize) runs. Which value is passed into the parameter?
A The text MySize
B 45, the value stored in MySize

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1CALL Line(60) AThe word CALL is missing, so the procedure is not called correctly. It should be CALL Line(60).
2CALL Line(MySize) BCALL Line(20)
3Calling the same procedure with a different value gives a different result, for example a shorter line. CFOR Count ← 1 TO 3 CALL Line(Count * 10) NEXT Count
4A procedure can be called in a loop so that each pass sends a new value into the parameter. DRuns the procedure Line and passes the value 60 into its parameter.
5Line(60) ERuns the procedure Line and passes the current value stored in the variable MySize into its parameter.
6CALL Line 60 FThe value is not in brackets. It should be CALL Line(60).

Definitions

CALL Line(60)

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
____ Line(60)
2.
CALL ____(60)
3.
MySize ← 40 CALL Line(______)
4.
FOR Count ← 1 TO 3 CALL Line(_____) NEXT Count
5.
FOR Count ← 1 TO 3 ____ Line(10) NEXT Count

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Line(60)
B CALL Line(90)
C OUTPUT "Done"
Question 2
A MySize ← 40
B CALL Line MySize
C OUTPUT "Finished"
Question 3
A DECLARE MySize : INTEGER
B MySize ← 25
C CALL Line("MySize")
Question 4
A FOR Count ← 1 TO 3
B CALL Line[Count * 20]
C NEXT Count
Question 5
A FOR Count ← 1 TO 4
B OUTPUT "Drawing"
C CALL Line(Size * 10)
D NEXT Count

Answer Key

Calling a procedure with a value
Section A: Quick Questions
Q1
A — CALL Line(60)
Q2
B — CALL Line(MySize)
Q3
A — Size takes the value 60 inside the procedure
Q4
A — The same procedure runs, but with different results because the values differ
Q5
B — 45, the value stored in MySize
Section B: Match the Pairs
Q1
CALL Line(60) → Runs the procedure Line and passes the value 60 into its parameter.
Q2
CALL Line(MySize) → Runs the procedure Line and passes the current value stored in the variable MySize into its parameter.
Q3
Calling the same procedure with a different value gives a different result, for example a shorter line. → CALL Line(20)
Q4
A procedure can be called in a loop so that each pass sends a new value into the parameter. → FOR Count ← 1 TO 3 CALL Line(Count * 10) NEXT Count
Q5
Line(60) → The word CALL is missing, so the procedure is not called correctly. It should be CALL Line(60).
Q6
CALL Line 60 → The value is not in brackets. It should be CALL Line(60).
Section C: Definitions
Q1
CALL Line(60) — CALL runs the procedure Line and passes the value 60 in brackets into its parameter. A variable can be passed too, e.g. CALL Line(MySize). Different values give different results.
Section D: Fill in the Blanks
Q1
CALL Line(60)
Q2
CALL Line(60)
Q3
MySize ← 40 CALL Line(MySize)
Q4
FOR Count ← 1 TO 3 CALL Line(Count) NEXT Count
Q5
FOR Count ← 1 TO 3 CALL Line(10) NEXT Count
Section E: Spot the Error
Q1
A — A procedure is run with the CALL keyword. The line must be CALL Line(60), not just Line(60).
Q2
B — The value being passed must be inside brackets after the procedure name. It should be CALL Line(MySize).
Q3
C — The quotes turn the variable name into a piece of text. To pass the value stored in the variable, write CALL Line(MySize) with no quotes.
Q4
B — The value passed to a procedure goes in round brackets, not square brackets. It should be CALL Line(Count * 20).
Q5
C — Size does not exist in this program, so there is no value to pass. The loop variable is Count, so the call should be CALL Line(Count * 10).