Britannica AI Icon

subprogram

computer science
Also known as: function, procedure, subroutine

Quick Summary

A subprogram, also known as a procedure, subroutine, or function, is a semi-independent portion of a computer program. These are essential building blocks in computer science, allowing programmers to break down complex tasks into smaller, more manageable parts.12

Think of a subprogram like a recipe that can be used within other recipes. It takes inputs, performs a specific set of operations, and produces an output or result. Commonly used subprograms are often stored in libraries provided with programming languages.2

Subprograms can also call other subprograms, creating a hierarchy of operations. In some cases, a subprogram can even call itself, a concept known as recursion, which can be a powerful way to solve problems that can be broken down into smaller, self-similar instances. This modular approach makes programs easier to write, understand, and maintain.2

Summary created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

Ask Britannica AI about this topic

Britannica doesn't have a full article on this topic, so we've curated a list of our relevant coverage.