Please answer each question fully, carefully and thoughtfully.
No credit will be given for unreadable answers, please write neatly.
Answer the questions in any order, but please number each answer.
Make sure that your name is on your test.
(8 points) Describe at least four ways functions make it easier to produce a working program.
Note, the question after this uses the answer from this question. Please read both before you answer either
(12 points) Write a complete program, which includes at least one function. This program should print the squares and cubes of the integers 0 through 10. Your output should look like this
(10 points) Clearly label each of the following elements in your program from the previous question. Describe the purpose of each.
Function Prototype
Function Invocation
Function Definition
Formal Parameter List
Actual Parameter List
(10 points) What is the difference between a variable, or pass by reference, and a value or pass by value parameter? When is each used? Give an example of a function which employs both.
(4 points) How must actual and formal parameters correspond?
(2 points) What is the difference between a local variable and a parameter?
(2 points) What is the scope of a variable?
(2 points) What is the lifetime of a variable?
(4 points) Give the syntax and describe the flow of control for the switch statement.
(10 points) Write a routine what takes an integer as input, between 0 and 9, and returns the English word (zero, one, ... nine) for that integer. You must use a switch statement in this routine.
(6 points) What is a stub routine, what is a test driver? Explain how and why each is used.
(5 points) Describe characteristics of documented code. Give
examples of both good and poor comments.
(5 points) Describe self documenting code. Give examples.