well rocky,
In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code. The syntax of many programming languages includes support for creating self-contained subroutines, and for calling and returning from them.
They are in many ways similar to mathematical functions, but can have side-effects outside of the simple "return value" that functions return (result in). Some programming languages make very little syntactic distinction between functions and subroutines.
There are many advantages to breaking a program up into subroutines, including:
* reducing the duplication of code in a program (e.g., by replicating useful functionality, such as mathematical functions),
* enabling reuse of code across multiple programs,
* decomposing complex problems into simpler pieces (this improves maintainability and ease of extension),
* improving readability of a program, and
* hiding or regulating part of the program (see Information hiding).
The components of a subroutine may include:
* a body of code to be executed when the subroutine is called,
* parameters that are passed to the subroutine from the point where it is called, and
* a value that is returned to the point where the call occurs.
Many programming languages, such as Pascal , Fortran, Ada, distinguish between functions or function subprograms, which return values (via a return statement), and subroutines or procedures, which do not. Some languages, such as C and Lisp, do not make this distinction, and treat those terms as synonymous. The name method is commonly used in connection with object-oriented programming, specifically for subroutines that are part of objects; it is also used in conjunction with type classes.
Maurice Wilkes, David Wheeler, and Stanley Gill are credited with the invention of the subroutine (which they referred to as the closed subroutine).
Answered by
Nz
, an ibibo Master,
at
6:25 PM on June 27, 2008