Home Segments Index Top Previous Next

5: Mainline

In contrast, procedure-oriented programming languages, such as C, encourage you to think in terms of functions and procedures, instead of in terms of classes and class hierarchies. Strictly speaking, functions are procedures that lack side effects. Nevertheless, function and procedure are used interchangeably.

Thus, to compute the square root of 2 using a procedure-oriented programming language, you must identify the appropriate function, which, when applied to 2—a datum of the integer data type—answers 1.41421, the function's value. Visually, the function has center stage; 2 is just the function's argument:

           Data-type specific function 
             | 
Argument     |                             Value answered     
  |          v                               | 
*-*        *---------------------*           | 
v          |                     |           v 
2 -------> | integer-square-root |-------> 1.41421 
           |                     | 
           *---------------------*