Chapter 10 Outcomes
Divide and Conquer: Subprograms
Knowledge Outcomes
Define each of the key terms listed in the chart below.
| median | average | sorting |
| function | procedure | predefined subprogram |
| local variable | formal parameter | actual parameter |
| variable parameter | fixed parameter | global variable |
| side effect | black box |
Define function and procedure.
Describe the difference between a pre-defined subprogram and a user-defined subprogram.
Describe the purpose of and utilize a variety of pre-defined functions and procedures such as:
| sqrt ( ) | length ( ) |
| index ( ) | locate ( ) |
| repeat ( ) | cls |
| colorback ( ) | color ( ) |
| round ( ) | chr ( ) |
| ord ( ) | delay ( ) |
Given the formal definition of a pre-defined function, state how many parameters it requires and the data type of the value being returned (as in appendix 2).
Given the formal definition of a pre-defined procedure, state how many parameters it requires and the data type of the parameters which are being passed (as in Appendix 2).
Explain the relationship between formal parameters, actual parameters, local variables, and the result of a function.
Describe the correspondence between the actual and formal parameters in a function with respect to the following:
Describe the correspondence between the actual and formal parameters in a procedure with respect to the following:
Describe what a variable parameter is. Be sure that you distinguish between the use of a variable parameter and a formal parameter that is not variable (fixed).
Distinguish between global variables and local variables. Be sure that you describe why global variables are not a desirable programming practice.
State the advantages of using subprograms. Explain why they are versatile and independent.
Skills Outcomes
Create simple user-defined functions.
Create simple user-defined procedures.
Identify local and global variables in a program.
Detect and correct a variety of common errors when creating subprograms as outlined in the chapter.