2.2.9

Modularity - Subroutines

Test yourself

Subroutines

A subroutine is a named block of code within your program.

Illustrative background for Advantages of subroutinesIllustrative background for Advantages of subroutines ?? "content

Advantages of subroutines

  • Easier to read:
    • There are fewer long blocks of code to understand.
  • More efficient:
    • Blocks of code can be written once and reused many times.
  • More reliable:
    • Each subroutine can be individually tested to make sure it works.
Illustrative background for Parameters and argumentsIllustrative background for Parameters and arguments ?? "content

Parameters and arguments

  • Parameters are special variables used to pass values into a subroutine.
  • Arguments are the actual values that are passed in.
Illustrative background for Types of subroutineIllustrative background for Types of subroutine ?? "content

Types of subroutine

  • A function is a subroutine which returns a value.
  • A procedure is a subroutine which does not return a value.

Jump to other topics

1Computer Systems

1.1Data Representation

1.2Data Transmission

1.3Hardware

1.4Software

1.5The Internet & its Uses

1.6Cyber Security

1.7Automated & Emerging Technologies

2Algorithms, Programming & Logic

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium