Preprocessor a standard programming language is often

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: and returns the square root of the number. Based on this criterion, subprograms are often categorized into two basic types: procedures and functions. A procedure is a subprogram that performs an action but returns no value. For example, a procedure might print a value or update a data structure. On the other hand, a function is a subprogram that returns a single value, as do mathematical functions like sine, cosine, absolute, square root. Both functions and procedures are widely used in general-purpose, high-level programming languages. Subprograms have the following distinct advantages: 1. They make it easier to write programs because the programmer can write less code. The same code can be called from many places in a program, instead of being duplicated everywhere it is needed. 2. Since only one copy of a subprogram's code is kept in the system instead of duplicating it everywhere it is needed, this leads to shorter source programs and their executable codes for programs that make use of subprograms. This leads to saving of storage space in the system and requirement of less memory space during the execution of a program. 3. Subprograms allow programs to be built in a modular fashion, which is essential to the construction of large software systems. 4. Modular design of software systems in the form of subprograms also provides the capability of compiling parts of a program (individual subprograms) without compiling the whole program (all subprograms used by the program). With such a capability, only the modules (subprograms) of a system that are being changed need to be recompiled during development or maintenance of the software system. Newly compiled and previously compiled modules (subprograms) are collected and put together by a program called linker. Without this capability, every change to a software system would require a complete recompilation. In a large system, this is costly. 5. Creating a subprogram for the task in question will obviate the need to do it again. This promise gives its author incentive to invest great care in generalizing it, debugg...
View Full Document

Ask a homework question - tutors are online