
MODULAR PROGRAMMING USING PROCEDURES AND FUNCTIONS
Modular programming is a technique used for writing large programs.
The program is subdivided into small sections. Each section is called a
module, and performs a single task.
Examples of tasks a module might perform are,
- displaying an option menu
- printing results
- calculating average marks
- sorting data into groups
A module is known by its name, and consists of a set of program
statements grouped using the begin and end keywords. The module
(group of statements) is executed when you type the module name.
Pascal uses three types of modules. The first two are called PROCEDURES,
the other a FUNCTION.
- Simple procedures do not accept any arguments (values or data) when
the procedure is executed (called).
- Complex procedures accept values to work with when they are executed.
- Functions, when executed, return a value (ie, calculate an answer
which is made available to the module which wants the answer)
Procedures help support structured program design, by allowing the
independant development of modules. Procedures are essentially sub-programs.
Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.
