Name: 
 

Lesson 4



True/False
Indicate whether the statement is true or false.
 

 1. 

The function declaration describes how the function performs its task.
 

 2. 

A formal parameter is a name following the parameter list type in a function heading
 

 3. 

Locally declared data are declared in the main block of the program.
 

 4. 

Value parameters are the parameters whose values are only passed from the caller to a function.
 

 5. 

The values of reference parameters are deallocated when the function returns to the caller.
 

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 6. 

A function declaration consists of ____.
a.
declaration list, function name
b.
block statement, function name
c.
return type, function name, parameter list
d.
function name, parameter list, statement list
 

 7. 

These kind of functions return no value:
a.
double
c.
main
b.
void
d.
integer
 

 8. 

Memory locations for local copies of value parameter are ____ when the function returns from its call.
a.
stored
c.
allocated
b.
deallocated
d.
devalued
 

 9. 

Which is not a parameter passing mode?
a.
string
c.
constant reference
b.
value
d.
reference
 

Completion
Complete each statement.
 

 10. 

The ____________________ parameters are the parameter list when calling the function from the main body of the program.
 

 

 11. 

The pairs in a formal parameter list consist of a(n) ____________________ name and a(n) ____________________ name.
 

 

 12. 

A statement of what must be true, before a function is invoked is a(n) ____________________, while a statement of what must be true, after the function has finished execution is a(n) ____________________.
 

 

 13. 

Because value parameters are passed by value, ____________________ of the value(s) are only active in memory while the function is active.
 

 

 14. 

____________________ identifiers are declared before the main block, while ____________________ identifiers are declared within the main block or a subblock.
 

 

 15. 

The only required difference between a function declaration and a function header is that the declaration must have a(n) ____________________ at the end.
 

 

 16. 

The function declarations are placed ____________________ the main function, while the implementations are placed ____________________.
 

 

 17. 

A function that does not use a void type must have a(n) ____________________ statement.
 

 

 18. 

Functions that do not return values are ____________________ functions.
 

 

 19. 

The minimum number of parameters in a function is ____________________.
 

 

 20. 

Parameters passed only from the caller to a function are called ____________________ parameters.
 

 

 21. 

Parameters that are passed to the function and back through the parameter list are called ____________________ parameters.
 

 

 22. 

Identifiers available to any subprogram are called ____________________ while those available in their own block or subblock are called ____________________.
 

 

Short Answer
 

 23. 

Functions that have the same form but can receive different types of parameters are what type of function?
 

 24. 

Write a function named myint that has no parameters and returns an integer.
 

 25. 

Write a function named mydouble that is passed one real number and returns a real number (not through the parameter list).
 

 26. 

Write a function named getValue that is passed two integers and returns a real number (not through the parameter list).
 

 27. 

Write a function named getChar that is passed an integer and returns a character (not through the parameter list).
 

 28. 

Write a function named getChar2 that is passed an integer and returns a character through the parameter list.
 

 29. 

Write a function named displayHeading that is passed nothing and nothing is returned.
 

 30. 

Write a function named convert which is passed two integers and returns two real numbers.
 

 31. 

Write a function named swap which is passed two characters and returns those two characters.
 

 32. 

Write a function named largest which is passed two integers and returns an integer (not through the parameter list).
 

 33. 

Write a function named getRatio that is passed two integers and returns the floating point ratio of the first number divided by the second. If the second number is zero, return a zero.
 

 34. 

Write a function named swap which is passed two characters and returns the same characters with their values exchanged.
 



 
Check Your Work     Start Over