Examo
PracticeAbout
Homecomputer-scienceProcedures and Functions
0984

Procedures and Functions

Programming · 4 question types

Practise
Download PDF

0984 Topics

Programming Concepts13%
Arrays5%
File Handling3%
Procedures and Functions4%
  1. Sub-programs: Why They Exist
  2. Procedures
  3. Functions
  4. Parameters and Arguments
  5. Procedures vs Functions: Side by Side
  6. Local and Global Variables (Scope)
  7. Pricing Airline Tickets with a Function

Frequency legend

High (≥14%)
Above avg (10 to 13%)
Average (<10%)

Exam Frequency Analysis

Past paper frequency (2018 to 2024)

This topic accounts for approximately 4% of your exam marks.

stable
Rare
Stable4%

Writing and calling procedures/functions with parameters is tested in Paper 2.

A real program may be hundreds or thousands of lines long. Writing it as one giant block of code would be hard to read, hard to test, hard to debug, and almost impossible to maintain. The solution is to break the program into named blocks that each do one specific job. These named blocks are called sub-programs.

Sub-programs make code:

  • Reusable: the same block can be called from many places, instead of being written out many times.
  • Easier to read: a well-named sub-program tells the reader what it does without making them read its body.
  • Easier to test: each sub-program can be tested on its own with chosen inputs.
  • Easier to maintain: a bug in one sub-program is fixed in one place, and the fix immediately applies everywhere that sub-program is called.

Cambridge IGCSE recognises two kinds of sub-program: procedures and functions.

The key difference: a function returns a value; a procedure does not.

Previous

File-handling Pitfalls

Next

Procedures