Benefits of Using Subprograms (Edexcel GCSE Computer Science)

Revision Note

Introduction to Using Subprograms

What is a subprogram? 

  • Subprograms are an out of line block of code that may be called by simply writing their name in a program     

  • Subprograms are given a unique name so they can be called anywhere in a program

  • There are many benefits to using Subprograms, these include

    • Making bigger problems easier to break down (decompose) and code

    • Allows team members to be able to work on different parts of a problem

    • Makes the program easier to debug

    • Makes programs more efficient as code is not duplicated

  • There are two main types of subprogram:

    • Procedures - does not return a result

    • Functions - returns one or more results to the calling code

Examples of using subprograms

Python code

# Subprogram 1 - Procedure

def Information() #define a subprogram named 'information'

    first_name = input("Enter a name")

    surname = input("Enter a name")

# Subprogram 2 - Function

def Tax(pay_per_hour, hours_worked) #define a subprogram that takes 2 parameters

    total = pay_per_hour * hours_worked

    net_pay = total * 0.8

    return net_pay

#Main program starts here

Information() #call subprogram 1
print(Tax) #call subprogram 2

Last updated:

You've read 0 of your 10 free revision notes

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.