Section 9.5: Subroutines (Frame 2)                     [prev][home][next]

The next program illustrates a simple subprogram, one that has two parameters. Some languages use the term procedure, while others, including C and C++ and Java, use function. The term subroutine is more common in assembler language. These names are generally equivalent, denoting a chunk of program code that can be used over and over again when a main program (or another subprogram) calls it.

More precise language stipulates that function is used to denote a subroutine that returns a value, since mathematical functions are similar. Inputs go into a function and an output comes out. Nothing else is changed. Procedure is used to denote a subroutine that does not return a value, but affects the outside world in some other way, such as doing input or output, changing global variables or even the state of the computer.