ANSWERS TO SELF TEST ON CHAPTER 7
1. We normally break down large or complex jobs into smaller tasks until they are small enough to
be completed.
2. This principle can be applied in programming by breaking the total job down and writing a
procedure for each task.
3. A simple procedure is:
a separate block of code
properly named. (two points)
4. A procedure call ensures that:
the procedure is activated
control returns to just after the calling point. (two points)
5. Procedure names can be used in a main program before the procedures have been written. This
enables you to think about the whole job and get an overview without worrying about the detail.
6. If you write a procedure definition before using its name you can test it and then when it works
properly forget the details. You need only remember its name and roughly what it does.
7. A programmer who can write up to thirty line programs can break down a complex task into
procedures in such a way that none is more than thirty lines and most are much less. In this way
he need only worry about one bit of the job at a time.
8. The use of a procedure would save memory space if it is necessary to call it more than once from
different parts of a program. The definition of a procedure only occurs once but it can be called as
often as necessary.
9. A main program can place information in 'pigeon-holes' by means of LET or READ statements.
These 'pigeon holes' can be accessed by the procedure. Thus the procedure uses information
originally set up by the main program.
A second method is to use parameters in the procedure call. These values are passed to
variables in the procedure definition which then uses them as necessary.
10. An actual parameter is the actual value passed from a procedure all in a main program to a
procedure.
11. A formal parameter is a variable in a procedure definition which receives the value passed to the
procedure by the main program.
CHECK YOUR SCORE
This is a searching test. You may need more experience of using procedures before the ideas can be
fully appreciated. But they are very powerful and, when understood, extremely helpful ideas. They are
worth whatever effort is necessary.
12 to 14 excellent. Read on with confidence.
10 or 11 very good. Just check again on certain points.
8 or 9 good but re-read some parts of chapter seven.
6 or 7 fair but re-read some parts of chapter seven. Work carefully through the programs writing down
all changes in variable values. Then do the test again.