WordGarden.io

subroutine

C2
Uncommon

Pronunciation

UK

    US

    • /ˈsəbruˌtin/

    Meanings

    Noun

    1. a self-contained set of instructions used within a larger computer program

    2. a smaller routine or repeated part within a larger process

    Beyond the definition

    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.

      • Patterncall 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.

    See also

    Similar

    Shades of meaning

    Contrast

    • main program
    • inline code

    Used with (collocations)

    • call a subroutine
    • subroutine call
    • define a subroutine
    • recursive subroutine

    Word family

    • sub-

    Explore

    Forms and spellings

    2 forms open this card.

    Main spelling

    • subroutinenoun

    Forms

    • subroutinespluralnoun