Calling a procedure with CALL

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

Calling a procedure with CALL

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly runs a procedure named DefaultLine that has no parameters?
A CALL DefaultLine
B DefaultLine
2. True or false: CALL DefaultLine is a complete statement and should be written on its own line.
A True
B False
3. A program has CALL DefaultLine on line 3 and OUTPUT "Done" on line 4. What happens after the procedure finishes?
A The program stops at line 3
B Control returns and line 4 runs next
4. The program has CALL DefaultLine written twice, one after the other. What happens?
A The procedure runs twice
B The procedure runs only once
5. Which is the correct way to call a procedure inside a selection? IF Score > 50 THEN ... ELSE ... ENDIF
A Write DefaultLine after the IF condition
B CALL DefaultLine on its own line inside THEN or ELSE

Match the Pairs

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

Left columnRight column
1CALL DefaultLine ARuns the same procedure twice, once for each CALL line
2CALL DefaultLine CALL DefaultLine BCALL is a complete statement on its own line and must not be placed inside OUTPUT. It should just be CALL DefaultLine.
3A procedure call is a complete statement, so it sits on its own line without OUTPUT or an assignment CIF score >= 50 THEN CALL DefaultLine ELSE CALL DefaultLine ENDIF
4CALL can be used inside a selection, so the procedure runs only when its branch is chosen DRuns the procedure named DefaultLine as a complete statement on its own line
5DefaultLine EThe keyword CALL is missing, so this is only a name and does not run the procedure. It should be CALL DefaultLine.
6OUTPUT CALL DefaultLine FCALL DefaultLine

Definitions

CALL DefaultLine

Fill in the Blanks

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

1.
____ DefaultLine
2.
CALL DefaultLine OUTPUT "Score" CALL ___________
3.
CALL DefaultLine OUTPUT "Menu" ____ DefaultLine
4.
IF Score > 50 THEN ____ DefaultLine ENDIF
5.
IF Score > 50 THEN CALL Pass ____ CALL Retry

Spot the Error

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

Question 1
A OUTPUT "Start"
B OUTPUT "Welcome"
C DefaultLine
Question 2
A OUTPUT "Scores"
B CALL DefaultLine
C DefaultLine CALL
Question 3
A RUN DefaultLine
B OUTPUT "Hello"
C CALL DefaultLine
Question 4
A IF Score > 50 THEN
B OUTPUT CALL PrintPass
C ELSE
D CALL PrintFail
E ENDIF
Question 5
A OUTPUT "Report"
B x ← CALL DefaultLine
C OUTPUT "Total: 5"

Answer Key

Calling a procedure with CALL
Section A: Quick Questions
Q1
A — CALL DefaultLine
Q2
A — True
Q3
B — Control returns and line 4 runs next
Q4
A — The procedure runs twice
Q5
B — CALL DefaultLine on its own line inside THEN or ELSE
Section B: Match the Pairs
Q1
CALL DefaultLine → Runs the procedure named DefaultLine as a complete statement on its own line
Q2
CALL DefaultLine CALL DefaultLine → Runs the same procedure twice, once for each CALL line
Q3
A procedure call is a complete statement, so it sits on its own line without OUTPUT or an assignment → CALL DefaultLine
Q4
CALL can be used inside a selection, so the procedure runs only when its branch is chosen → IF score >= 50 THEN CALL DefaultLine ELSE CALL DefaultLine ENDIF
Q5
DefaultLine → The keyword CALL is missing, so this is only a name and does not run the procedure. It should be CALL DefaultLine.
Q6
OUTPUT CALL DefaultLine → CALL is a complete statement on its own line and must not be placed inside OUTPUT. It should just be CALL DefaultLine.
Section C: Definitions
Q1
CALL DefaultLine — CALL followed by a procedure name runs that procedure. It is a complete statement written on its own line, e.g. CALL DefaultLine. Control returns to the next line afterwards.
Section D: Fill in the Blanks
Q1
CALL DefaultLine
Q2
CALL DefaultLine OUTPUT "Score" CALL DefaultLine
Q3
CALL DefaultLine OUTPUT "Menu" CALL DefaultLine
Q4
IF Score > 50 THEN CALL DefaultLine ENDIF
Q5
IF Score > 50 THEN CALL Pass ELSE CALL Retry
Section E: Spot the Error
Q1
C — A procedure is run with a CALL statement. Writing only the name does not run it. Line 3 should be CALL DefaultLine.
Q2
C — The keyword CALL must come first, followed by the procedure name. Line 3 should be CALL DefaultLine.
Q3
A — The keyword that runs a procedure is CALL, not RUN. Line 1 should be CALL DefaultLine.
Q4
B — CALL is a complete statement on its own line. It is not a value to put inside OUTPUT. Line 2 should be CALL PrintPass.
Q5
B — A procedure does not return a value, so its result cannot be stored in a variable. Line 2 should be just CALL DefaultLine.