WordGarden.io
Back to search

subroutine

C2
noun

Pronunciation

UK

  • /sˈʌbruːtˌiːn/

US

  • /ˈsəbruˌtin/

Description

Imagine you're building with LEGO bricks. You might create a small, self-contained structure—like a little car or a tower—that you then use repeatedly as part of a much bigger creation, perhaps a whole city! That smaller, modular structure is very much like a subroutine in computer programming.

A subroutine is essentially a mini-program nestled within a larger program. It is a set of instructions designed to perform one specific task. Programmers write subroutines so they don't have to rewrite the same code over and over again. Instead, they can simply "call" the subroutine whenever that task needs to be executed. Think of it as a shortcut for common actions. While subroutines are often referred to as functions or procedures, their core purpose remains the same: to make code cleaner, more efficient, and much easier to manage.

Examples

  1. 1

    Password check

    The program uses a subroutine to check whether the user's password is valid.

  2. 2

    Error handling

    If the file is empty, the main code calls a subroutine that shows an error message.

    • Pattern

      call a subroutine

      run it from another part of the program

  3. 3

    Reusable code

    Instead of writing the same code three times, she put it into a reusable subroutine.

  4. 4

    Program testing

    We broke the task into smaller subroutines so the program would be easier to test.

Forms and spellings

2 forms open this card.

Main spelling

  • subroutinenoun

Forms

  • subroutinespluralnoun