Functions Part1 Tut
Functions Part1 Tut
1
▪ The most important reason to use functions is to aid in the conceptual organization
of a program.
▪ Another reason to use functions (and the reason they were invented, long ago) is to
reduce program size.
2
Declaration
Call
Definition
3
Declaration
Definition
Call
4
▪ Passing Constants
5
▪ Passing Variables
6
▪ Passing Variables by Value
7
▪ Passing Variables by Reference
8
9
▪ We can only use return to return one
variable only
10
1. A function’s single most important role is to:
a. give a name to a block of code.
b. reduce program size.
c. accept arguments and provide a return value.
d. help organize a program into conceptual units.
A function argument is :
a. variable in the function that receives a value from the
calling program.
b. way that functions resist accepting the calling program’s
values.
c. value sent to the function by the calling program.
d. value returned by the function to the calling program.
11. Which of the following can legitimately be passed to a
function?
a. A constant
b. A variable
c. A structure
d. A header file
A default argument has a value that
a. may be supplied by the calling program.
b. may be supplied by the function.
c. must have a constant value.
d. must have a variable value.
11
12
13
14
15