Subroutine Encyclopedia Article

Subroutine

The following sections of this BookRags Literature Study Guide is offprint from Gale's For Students Series: Presenting Analysis, Context, and Criticism on Commonly Studied Works: Introduction, Author Biography, Plot Summary, Characters, Themes, Style, Historical Context, Critical Overview, Criticism and Critical Essays, Media Adaptations, Topics for Further Study, Compare & Contrast, What Do I Read Next?, For Further Study, and Sources.

(c)1998-2002; (c)2002 by Gale. Gale is an imprint of The Gale Group, Inc., a division of Thomson Learning, Inc. Gale and Design and Thomson Learning are trademarks used herein under license.

The following sections, if they exist, are offprint from Beacham's Encyclopedia of Popular Fiction: "Social Concerns", "Thematic Overview", "Techniques", "Literary Precedents", "Key Questions", "Related Titles", "Adaptations", "Related Web Sites". (c)1994-2005, by Walton Beacham.

The following sections, if they exist, are offprint from Beacham's Guide to Literature for Young Adults: "About the Author", "Overview", "Setting", "Literary Qualities", "Social Sensitivity", "Topics for Discussion", "Ideas for Reports and Papers". (c)1994-2005, by Walton Beacham.

All other sections in this Literature Study Guide are owned and copyrighted by BookRags, Inc.

Subroutine

A subroutine, which can also be commonly called a routine, is a section of a computer program that performs a particular task. Subroutines are sets of computer instructions that exist and run within a program.

Computer programs can be written as a single document. However, this format can be cumbersome when checking for programming defects. Accordingly, many programs are now written in more easily managed sections. Each of these sections, which can also be termed a module (or modulus), is made up of one or more subroutines/routines. The concerted performance of the various tasks specified by the subroutines enables the program to function.

Subroutines can be used repeatedly during the execution of a program. This makes a program shorter and easier to write, as redundant sections are eliminated. A subroutine can be invoked during the running of a program and, when finished, that subroutine can branch back to the next instruction following the one that branched to it.

Subroutines are often parts of computational programs. Following a prompted format, the user inputs data (for example, a number specifying a temperature in degrees Celsius) the program then immediately accesses a conversion subroutine to add 273.15 to the number to convert the number to the Kelvin scale) the use of the input and conversion subroutine saves many programming lines that would otherwise be dedicated to performing this repetitious task for separate data entry items. Branching to subroutines also permits programs to directly access needed programming steps without having to run through unneeded code.

A subroutine may also be useful in more than one program and a subroutine code may be capable of being shared by multiple programs. Subroutines may also be packaged together with an interface to allow their use for a specific function such as those exemplified by Library routines.