Writing a short program with a procedure and a function
The section after all procedure and function definitions. It calls them in order, using CALL for procedures and function calls inside expressions or OUTPUT.
Understanding Writing a short program with a procedure and a function in IGCSE Computer Science Paper 2
What it does: The definition block comes first, so the main program below can call ShowMenu. The main program calls the function in an assignment and then outputs the stored result, in order. A procedure is called with CALL on its own line. It does not return a value, so it cannot be stored in a variable. A function call can sit inside OUTPUT because it produces a value. CALL is only used for procedures. The call must give one argument for each of the three parameters, in the right order. Move the PROCEDURE definition above the CALL so the definitions come at the start.
Common mistakes: A procedure does not send a value back, so it cannot use RETURN. It should show the text with OUTPUT "Quiz Time". A function must send its answer back to the main program with RETURN. It should be RETURN N * N, so that OUTPUT Sq(5) can show the result.
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 419–428) and word search (Modules 419–438).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
main programFill in the Blanks
Spot the Error
Student with a class code? Join your class →