This essay Procedures, Parameters & Sub-Programs has a total of 963 words and 6 pages.
Procedures, Parameters & Sub-Programs
In any modern programming language, procedures play a vital role in the
construction of any new software. These days, procedures are used instead of
the old constructs of GOTO and GOSUB, which have since become obsolete.
Procedures provide a number of important features for the modern software
Programs are easier to write. Procedures save a large amount of time during
software development as the programmer only needs to code a procedure once, but
can use it a number of times. Procedures are especially useful in recursive
algorithms where the same piece of code has to be executed over and over again.
The use of procedures allows a large and complex program to be broken up into a
number of much smaller parts, each accomplished by a procedure. Procedures also
provide a form of abstraction as all the programmer has to do is know how to
call a procedure and what it does, not how it accomplishes the task.
Programs are easier to read. Procedures help to make programs shorter, and thus
easier to read, by replacing long sequences of statements with one simple
procedure call. By choosing goo procedure names, even the names of the
procedures help to document the program and make it easier to understand.
Programs are easier to modify. When repeated actions are replaced by one
procedure call, it becomes much easier to modify the code at a later stage, and
also correct any errors. By building up the program in a modular fashion via
procedures it becomes much easier to update and replace sections of the program
at a later date, if all the code for the specific section is in a particular
Programs take less time to compile. Replacing a sequence of statements with
once simple procedure call usually reduces the compilation time of the program,
so long as the program contains more than one reference to the procedure!
Object programs require less memory. Procedures reduce the memory consumption
of the program in two ways. Firstly they reduce code duplication as the code
only needs to be stored once, but the procedure can be called many times.
Secondly, procedures allow more efficient storage of data, because storage for a
procedure\'s variables is allocated when the procedure is called and deallocated
when it returns.
We can divide procedures into two groups:-
Function procedures, are procedures which compute a single value and whose calls
appear in expressions
For example, the procedure ABS is a function procedure, when given a number x,
ABS computes the absolute value of x; a call of ABS appears in an expression,
representing the value that ABS computes.
Proper procedures, are procedures whose calls are statements
For example, the procedure INC is a proper procedure. A call of INC is a
statement; executing INC changes the value stored in a variable.
Procedures have only one real disadvantage: Executing a procedure requires
extra time because of the extra work that must be done both when the procedure
is called, and when it returns.
Most of the time however, the advantages of using procedures heavily outweigh
this minor disadvantage.
Most procedures depend on data that varies from one call to the next, and for
this reason, Modula-2 allows a procedure heading to include a list of
identifiers that represent variables or expressions to supply when calling the
procedure. The programmer can use these identifiers, known as formal
parameters, in the body of the procedure in the same fashion as ordinary
A call of a procedure with parameters must include a list of actual parameters.
The number of actual parameters must be the same as the number of formal
parameters. Correspondence between the actual and formal parameters is by
position, so the first actual parameter corresponds to the first formal
parameter, the second actual parameter corresponds to the second formal
parameter, and so on. The type of each actual parameter must match the type of
the corresponding formal parameter.
Modula-2 provides to kinds of formal parameters:-
Variable parameters. In a procedure heading, if the reserved word VAR precedes
a formal parameter, then it is a variable parameter. Any changes made to a
variable parameter within the body of the procedure also affect the
corresponding actual parameter in the main body of the program.
Value parameters. If the reserved word VAR does not precede a formal parameter
then it is a value parameter. If a formal parameter is a value parameter, the
corresponding actual parameter is protected from change, no matter what changes
are made to the corresponding parameter in the procedure.
To sum up, variable parameters allow information to flow both into and/or out of
a procedure, whereas
Topics Related to Procedures, Parameters & Sub-Programs
Subroutines, Parameter, IBM i Control Language, Entry point, Variable, Return statement, Interprocedural optimization, Scope
Essays Related to Procedures, Parameters & Sub-Programs
The History and Future of ComputersThe History and Future of Computers Tim Gash CRS-07 Mr. Drohan January 31, 1997 With the advances in computer technology it is now possible for more and more Canadians to have personal computers in their homes. With breakthroughs in computer processing speeds and with computer storage capacity, the combination of this with the reduced size of the computer have allowed for even the smallest apartment to hold a computer. In the past the only places to have computers were military institutes and so
Development of Computers and TechnologyDevelopment of Computers and Technology Computers in some form are in almost everything these days. From Toasters to Televisions, just about all electronic things has some form of processor in them. This is a very large change from the way it used to be, when a computer that would take up an entire room and weighed tons of pounds has the same amount of power as a scientific calculator. The changes that computers have undergone in the last 40 years have been colossal. So many things have changed
Naming Conventions (Hungarian)Naming Conventions (Hungarian) Doug Klunder January 18, 1988 1. Introduction This document describes a set of naming conventions used by the Applications Development group. These conventions commonly go by the name Hungarian, referring both to the nationality of their original developer, Charles Simonyi, and also to the fact that to an uninitiated programmer they are somewhat confusing. Once you have gained familiarity with Hungarian, however, we believe that you will find that the clarity of
Software Engineering Overview Software Engineering Overview Let us first understand what software engineering stands for. The term is made of two words, software and engineering. Software is more than just a program code. A program is an executable code, which serves some computational purpose. Software is considered to be collection of executable programming code, associated libraries and documentations. Software, when made for a specific requirement is called software product. Engineering on the other hand, is all a