& Sub-Programs Essay, Research Paper
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
engineer:-
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
module.
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
variables.
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 value parameters are one way and only allow information
into a procedure.
Most Modula-2 systems allow a program to “call” a program module as if it were a
procedure. We call a module used in this way a subprogram module or just a
subprogram. The commands for calling another program are not part of Modula-2
itself, but are provided by a procedure in a library module. The command used
in most Modula-2 systems for calling a sub-program is CALL, and a number of
parameters are usually passed along with this procedure so as to allow the two
programs to communicate with each other, but there is no way to supply
parameters to a subprogram. The parameters passed only indicate things like
whether the sub-program was executed correctly and did not terminate early
because of an error.
The primary reason for using subprograms is to reduce the amount of memory
required to execute a program. If a program is too large to fit into memory,
the programmer can often identify one or more modules, that need not exist
simultaneously. The main module can then call these modules as subprograms when
needed. Once a subprogram has completed execution, it returns control to the
main program, which can then call another sub program. All subprograms share
the same area of memory, and because only one is resident at a time, the memory
requirements of the overall program are greatly reduced.
Другие работы по теме:
Разработка регулятора температуры обратной воды калорифера
Применение ИС программирования КОНГРАФ в работе над проектом регулятора температуры воды калорифера в зависимости от температуры наружного воздуха. Структурная схема алгоритма регулятора температуры горячей воды калорифера, разработка блоков проекта.
PLANTS Essay Research Paper With the everincreasing
PLANTS Essay, Research Paper With the ever-increasing problem of pest control, it is clear that some form biological must be implemented in order to help farmers. This biological control must be able to effectively control the pest population, this means not killing them but rather never letting the pest populations get too large.
Untitled Essay Research Paper LAW an Overview
Untitled Essay, Research Paper LAW: an Overview Human nature consists of three basic components. These are to live, to propagate and to dominate. If Humanity was left without any other parameters, this natural state of existence would govern its behavior. Fortunately, there are parameters that exist.
Log Shipping Essay Research Paper The concept
Log Shipping Essay, Research Paper The concept of standby servers is not a new one. It has been around a long time and been used by many DBAs. Traditionally, using a standby server for failover has involved manually making database and log backups on the production server and then restoring them to the standby server on a regular basis.
Ethics Of Genetic Enginerring Essay Research Paper
Ethics of Genetic Engineering Richard Williams proposed that the issue of human freedom be re-conceptualized. Rejecting the traditional view of self-direction as the possibility of choosing among alternatives, Williams suggested that we ground our understanding of individual freedom in morality.
Aborigines Essay Research Paper The Aborigines of
Aborigines Essay, Research Paper The Aborigines of Australia can be viewed in three different views. All cultures have the basic three different categories. These three categories form a pyramid. At the bottom of the pyramid is technology. Technology is anything the culture uses to aid themselves. In the middle of the pyramid is social system.
The Birthmark 2 Essay Research Paper Response
The Birthmark 2 Essay, Research Paper Response Paper #2: The Birthmark 1. Our society tends to be obsessed with the idea of physical perfection. How does our society manifest that obsession? How is the Birthmark an early version of our modern obsession with physical perfection?
Environmental Scanning Essay Research Paper This paper
Environmental Scanning Essay, Research Paper This paper will discuss environmental scanning, marketing procedures, and describe how the environment affects marketing in relation to the automobile detailing business.
Technology Essay Research Paper How Technology Has
Technology Essay, Research Paper How Technology Has Changed The Way Businesses Work Technology has definitely changed the way businesses operate today. Over the last three years many standard procedures have now become obsolete. With the invasion of the Internet the entire picture has changed. Business has had to quickly transform to keep up with the technological
Hydrostatic Weighing Essay Research Paper During the
Hydrostatic Weighing Essay, Research Paper During the past 68 years many laboratory procedures have been developed to analyze the body in relation to its three major structural components: fat, muscle, and bone. Some of the procedures are time-consuming and require the use of sophisticated, expensive laboratory equipment, while other procedures are fairly simple and inexpensive.
Statistics Essay Research Paper IntroductionStatistics are used
Statistics Essay, Research Paper Introduction Statistics are used everyday in life, and are very important in the everyday world. One important use of statistics is to summarize a collection of data in a clear and understandable way. For example, if a psychologist gave a personality test measuring shyness to all 2500 students attending a small college, How might these measurements be summarized? There are two basic methods: numerical and graphical.
Assembly Language Essay Research Paper When programming
Assembly Language Essay, Research Paper When programming in assembly language, we have to specify operations in a much greater level of detail than we would have to do in a high level language. Furthermore, we get relatively little help from the assembler in finding errors. Assemblers can only check the syntax of each line, and check that every symbol or label used is defined somewhere.
Herbal Supplements And Mice Essay Research Paper
A nutritional scientist was trying to get a new herbal supplement approved by the Food and Drug Administration. Her belief is that the herbal supplement can improve endurance in humans. The scientist took 30 mice and split them into 15 groups of two mice. The two mice in each group are of the same species, have same diet patterns, and same size.
The Movies Essay Research Paper The speaker
The Movies Essay, Research Paper The speaker in the movie viewed in class on February 5, 2001 gave a very good presentation on the procedures performed during C.P.R. and the benefits of knowing this life saving procedure. Although the speech was audience capturing, there were a few improvements that would have helped improve her presentation.
The History Of Surgery Essay Research Paper
Surgery is the branch of medicine that deals with the treatment of disease, deformities, or injuries by operations. Surgery has been around for thousands of years, dating all the way back to the ancient Egyptians. Throughout this time period many methods and operations were created and perfected to what is now commonly practiced in modern times.
Euthanasia Essay Research Paper EuthanasiaEuthanasia is just
Euthanasia Essay, Research Paper Euthanasia Euthanasia is just another word for ?mercy killing? as some people put it but it also means good death. I look at it as more of a good death if it is performed with the right procedures and if a person has a legitimate reason to be put to death but many people would not agree with me that it should be legal.
Is Abortion Murder Or Not Essay Research
Paper Alex Ausmanas Mr. David R. Connely Political Science 101W February 7, 2001 Is Abortion Murder or Not? The topic of abortion has been widely argued across the nation for many years. People have been getting abortions way before the Wade v. Roe case and as soon as it hit the courts the country came to life.
Transfer Essay Research Paper Procedures for Transferring
Transfer Essay, Research Paper Procedures for Transferring to a University in the United States There are several steps that a prospective international student should follow in order to transfer to study at a university in the United States. These steps that are outlined below will normally take about one year to complete, particularly if application is also being made for scholarship support.
Data Mining Essay Research Paper In today
Data Mining Essay, Research Paper In today s business world, information about the customer is a necessity for a businesses trying to maximize its profits. A new, and important, tool in gaining this knowledge is Data Mining. Data Mining is a set of automated procedures used to find previously unknown patterns and relationships in data.
Child Development And Mathematical Procedure Essay Research
Paper Child Development and Mathematical Procedure Carroll, William and Porter, Denise. “Invented Strategies Can Develop Meaningful Mathematical Procedures.” Teaching Children Mathematics 3 (March 1997): 370-373. NCTM Standard 1 for K-4 goal is to “develop and apply strategies to solve a wide variety of problems” and to “acquire confidence in using math meaningfully.” Standard 3 promotes children “using models an relationships to explain their thinking and justify their answers and processes.” Both of these standards are well utilized by this article’s approach.
Pushing An Object Essay Research Paper Pushing
Pushing An Object Essay, Research Paper Pushing an object When an object with mass is moving, that it has kinetic energy is well known. Energy quantity can be expressed in two parameters of the mass and the speed. Generally definition of energy is difficult, though the quantity can be measured easily.
Faa Enforcement Actions Essay Research Paper FAA
Faa Enforcement Actions Essay, Research Paper FAA Enforcement Actions The Aircraft Owners and Pilots Association (AOPA) handbook of the Federal Aviation Administration (FAA) enforcement actions gives us a very comprehensive explanation about FAA actions and how to deal with them if we are involved in some case of violation of the FARs.
Informed Consent Essay Research Paper Informed ConsentA
Informed Consent Essay, Research Paper Informed Consent A legal document that has been written and processed through the courts is called Informed Consent. An Informed Consent Document requires that doctors give all patients important information about his/her own procedure before the surgery or the treatment takes place.
Euthanasia Essay Research Paper EUTHANASIA When most
Euthanasia Essay, Research Paper EUTHANASIA When most people think of euthanasia, they think merely of death. Death usually has a negative connotation to it although often times it may be beneficial. This understanding is fundamental to euthanasia. The roots words for euthanasia, eu and thantos, mean good and death respectively (Humphrey Dying With Dignity 80).
Managing A PC Essay Research Paper Managing
Managing A PC Essay, Research Paper Managing A Personal Computer 1.1 The AUTOEXEC.BAT file is one of files which loads every time the computer is booted. It contains command lines and procedures to run programs and load settings for the system?s hardware and software configuration. It also may contain command lines procedures to run programs which may clean your system?s hard drive of temporary files and viruses.
Arrest Analysis Essay Research Paper Arrest
Arrest Analysis Essay, Research Paper Arrest: – An arrest is the act of depriving an individual of his liberty by legal authority. This is to inform you the two procedures of arrest. The procedures of arrest are warrant and non-warrant.
Ethical Procedures And Guidelines Defining Pschycological Research
Essay, Research Paper Ethical Procedures and Guidelines Defining Pschycological Research Psychological research is often a very controversial subject among experts. Many people feel thatthere are many moral standards that are often not followed. Others may believe that there is much harmful misinformation that can often be harmful to subject and others.
Canadian Health Care VS US Health Care
Essay, Research Paper One of the major differences between the U.S. and Canadian health care system is the payment system. In the United States, physicians are paid more for doing more, and the return on their time is higher if they perform a procedure than if they use their cognitive skills. Because of the fact that procedures often require hospital care, this approach translates into higher expenditures for hospital care.
Object Orientated Computing Essay Research Paper The
Object Orientated Computing Essay, Research Paper The object orientated approach has changed the way in which computing and programming has been done in the past. These changes affect almost everyone and with computing technology becoming more and more integrated with business and every day life it is useful to look at the importance of these changed to the technology industry.
Inherit The Wind Think Piece Essay Research
Paper Inherit the Wind Think Piece In today’s society, where angry children shoot, bomb, and threaten their schoolmates, there exists a rather incoherent line between appropriate classroom conversation and unacceptable discussion. True, this line did not exist some years ago, but as times changed, so did certain parameters.
Embezzlement Essay Research Paper Mac Taylor
Embezzlement Essay, Research Paper Mac Taylor’s Embezzlement Due Process Rights Mac Taylor is employed by American National Bank located in Bowling Green, Kentucky. He has been arrested