← IGCSE Computer Science Paper 2

Writing a main program that calls one procedure per sub-problem

Runs a procedure. A main program is a short list of CALL lines, one per sub-problem from the structure diagram, in the right order, with no detail inside it.

Understanding Writing a main program that calls one procedure per sub-problem in IGCSE Computer Science Paper 2

What it does: Three sub-problems in the structure diagram give three CALL lines. The detail of each step lives inside its own procedure. GetInputs comes before Calculate because Calculate needs the input values. Reversing them would use values that do not exist yet. The main program calls one procedure per sub-problem, in the order the work must happen: inputs first, then the calculation, then the results. The keyword CALL comes first, followed by the procedure name. CALL Calculate runs the procedure. The second version puts detail (INPUT and OUTPUT) directly in the main program. The detail should be inside GetInputs and ShowResults instead.

Common mistakes: Each sub-problem in the main program needs the keyword CALL. It should be CALL GetInputs, otherwise the procedure is not run. Pseudocode keywords must be written in capitals. The line should be CALL ShowResults.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 136–145) and word search (Modules 123–145).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A structure diagram has three sub-problems: GetInputs, Calculate and ShowResults. Which main program matches it?
CALL GetInputs CALL ShowResults CALL CalculateCALL GetInputs CALL Calculate CALL ShowResults
Matches
CALL ShowResults CALL Calculate CALL GetInputs
↓
The calls are in the wrong order. The results are shown before they are calculated and before the inputs are entered.
Applying
Meanings
Term
CALL
Meaning
Runs a procedure. A main program is a short list of CALL lines, one per sub-problem from the structure diagram, in the right order, with no detail inside it.
Practice
CALL GetInputs
Testing
Gaps
GetInputs
Check Answer
Spots
1GetInputs
2CALL Calculate

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Hermit Crab' badge — Definition Collector, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A structure diagram has three sub-problems: GetInputs, Calculate and ShowResults. Which main program matches it?
A. CALL GetInputs CALL ShowResults CALL Calculate
B. CALL GetInputs CALL Calculate CALL ShowResults ✓
The main program calls one procedure per sub-problem, in the order the work must happen: inputs first, then the calculation, then the results.
2. Which line correctly runs a procedure called Calculate from the main program?
A. Calculate CALL
B. CALL Calculate ✓
The keyword CALL comes first, followed by the procedure name. CALL Calculate runs the procedure.
3. What should a main program in a decomposed solution contain?
A. A short list of CALL statements, one for each sub-problem ✓
B. All the INPUT, calculation and OUTPUT code written out in full
The detail belongs inside the procedures. The main program only calls them, so it stays short and easy to read.
4. Why must CALL GetInputs come before CALL Calculate?
A. Calculate needs the input values, so they must be collected first ✓
B. Pseudocode always runs procedures in alphabetical order
The order of the calls matters. The program runs the lines from top to bottom, so data must be collected before it is used.
5. A structure diagram has four sub-problems under the top-level box. How many CALL lines should the main program have?
A. Four, one for each sub-problem ✓
B. One, because there is only one main program
Each sub-problem on the structure diagram becomes one procedure, and the main program has one CALL line for each.

Match the Pairs

CALL GetInputs → Runs the procedure that handles the input sub-problem, so the main program holds no input detail
CALL ShowResults → Runs the output sub-problem as the last step of the main program, after the calculation is done
A main program is a short list of CALL statements, one per sub-problem, with no detail inside it → CALL GetInputs CALL Calculate CALL ShowResults
The order of the calls matters: inputs must be collected before they are used in a calculation → CALL GetInputs CALL Calculate
CALL ShowResults CALL Calculate CALL GetInputs → The calls are in the wrong order. The results are shown before they are calculated and before the inputs are entered.
CALL GetInputs INPUT Length CALL Calculate CALL ShowResults → The main program contains detail (INPUT Length) instead of only CALL statements. The detail belongs inside the GetInputs procedure.

Key Term

CALL
Runs a procedure. A main program is a short list of CALL lines, one per sub-problem from the structure diagram, in the right order, with no detail inside it.

Fill in the Blanks

1. CALL GetInputs CALL Calculate CALL ShowResults
Hint: Type the keyword that runs a procedure from the main program
2. CALL GetInputs CALL Calculate CALL ShowResults
Hint: Type the name of the procedure for the processing sub-problem
3. CALL GetInputs CALL Calculate CALL ShowResults
Hint: Type the name of the procedure that outputs the answer to the user
4. CALL GetInputs CALL Calculate CALL ShowResults
Hint: Type the name of the procedure that must run first to collect the data
5. CALL GetInputs CALL Calculate CALL ShowResults
Hint: Type the keyword every line of this short main program starts with

Spot the Error

Question 1
A GetInputs
B CALL Calculate
C CALL ShowResults
Line A — Each sub-problem in the main program needs the keyword CALL. It should be CALL GetInputs, otherwise the procedure is not run.
Question 2
A CALL GetInputs
B CALL Calculate
C CALL CheckResult
D call ShowResults
Line D — Pseudocode keywords must be written in capitals. The line should be CALL ShowResults.
Question 3
A CALL GetInputs
B CALL Calculate
C CALL ShowResults
D Total ← Score1 + Score2
Line D — The main program must contain no detail. The calculation belongs inside the Calculate procedure, so this line should be CALL SaveScores, which runs the last sub-problem.
Question 4
A CALL ShowResults
B CALL Calculate
C CALL ShowResults
Line A — The order of the calls matters. Results cannot be shown before the data is input and processed. Line 1 should be CALL GetInputs.
Question 5
A CALL GetInputs
B RUN Calculate
C CALL ShowResults
Line B — Pseudocode uses CALL to run a procedure, not RUN. The line should be CALL Calculate.

Student with a class code? Join your class →