Documente Academic
Documente Profesional
Documente Cultură
Functions
What is the output of the following program?
Answer
5
2
7
"getValue(x)"
A function ________ eliminates the need to place a function definition before all calls to
the function.
Answer
header
prototype
argument
parameter
None of these
________ functions may have the same name, as long as their parameter lists are
different.
Answer
Only two
Two or more
Zero
Un-prototyped
None of these
A(n) ________ argument is passed to a parameter when the actual argument is left out
of the function call.
Answer
false
true
null
default
None of these
This is a dummy function that is called instead of the actual function it represents.
Answer
main function
stub
driver
overloaded function
Here is the header for a function named computeValue:
Which of the following is a valid call to the function?
Answer
computeValue(10)
computeValue(10);
void computeValue(10);
void computeValue(int x);
What is the output of the following program?
Answer
2
2
4
2
2
4
4
4
EXIT_FAILURE and ________ are named constants that may be used to indicate
success or failure when the exit( ) function is called.
Answer
EXIT_TERMINATE
EXIT_SUCCESS
EXIT_OK
RETURN_OK
None of these
Which line in the following program contains a call to the showDub function?
Answer
4
6
10
15
Functions are ideal for use in menu-driven programs. When a user selects a menu item,
the program can ________ the appropriate function.
Answer
call
prototype
define
declare
None of these
A ________ variable is declared outside all functions.
Answer
local
global
floating-point
counter
None of these
Look at the following function prototype.
What is the data type of the funtion's parameter variable?
Answer
int
double
void
can't tell from the prototype
This statement causes a function to end.
Answer
end
terminate
return
release
None of these
If a function is called more than once in a program, the values stored in the function's
local variables do not ________ between function calls.
Answer
persist
execute
communicate
change
None of these
A function ________ contains the statements that make up the function.
Answer
definition
prototype
call
expression
parameter list
A(n) ________ is information that is passed to a function, and a(n) ________ takes the information that is passed to
the function.
Answer
function call, function header
parameter, argument
argument, parameter
prototype, header
None of these
This function causes a program to terminate, regardless of which function or control
mechanism is executing.
Answer
terminate( )
return( )
continue( )
exit( )
None of these
When used as parameters, these types of variables allow a function to access the
parameter's original argument.
Answer
reference
floating-point
counter
undeclared
None of these
What is the output of the following program?
Answer
2
0
2
2
2
2
0
0
0
2
0
0
Which line in the following program contains the prototype for the showDub function?
Answer
4
6
10
15
A function can have zero to many parameters, and it can return this many values.
Answer
zero to many
no
only one
a maximum of ten
None of these
This type of variable is defined inside a function and is not accessible outside the
function.
Answer
global
reference
local
counter
None of these
It is a good programming practice to ________ your functions by writing comments that
describe what they do.
Answer
execute
document
eliminate
prototype
None of these
Which of the following statements about global variables is true?
Answer
A global variable is accessible only to the main function.
A global variable is declared in the highest-level block in which it is used.
A global variable can have the same name as a variable that is declared locally within a
function.
If a function contains a local variable with the same name as a global variable, the global
variable's name takes precedence within the function.
All of these are true
What is the output of the following program?
Answer
2
0
2
2
2
2
0
0
0
2
0
0
The value in a(n) ________ variable persists between function calls.
Answer
dynamic
local
counter
static local
Look at the following function prototype.
How many parameter variables does this function have?
Int myfunction (double,double,double)
Answer
1
2
3
can't tell from
the prototype
These types of arguments are passed to parameters automatically if no
argument is provided in the function call.
Answer
local
default
global
relational
None of these
In a function header, you must furnish:
Answer
data type(s) of the parameters
data type of the return value
the name of function
names of parameter variables
All of these
A function is executed when it is:
Answer
defined
prototyped
declared
called
None of these
This is a collection of statements that performs a specific task.
Answer
infinite loop
variable
constant
function
None of these
This is a statement that causes a function to execute.
Answer
for loop
do-while loop
function prototype
function call
None of these
Given the following function definition
Answer
1 2 3
1 6 3
3 6 3
1 14 9
None of these
The value in this type of local variable persists between function calls.
Answer
global
internal
static
dynamic
None of these
If a function does not have a prototype, default arguments may be
specified in the function ________.
Answer
call
header
execution
return type
None of these
Which line in the following program contains the header for the showDub
function?
Answer
4
6
10
15
ook at the following function prototype.
What is the data type of the funtion's return value?
Answer
int
double
void
can't tell from the prototype
Arrays
If you leave out the size declarator in an array definition:
Answer
you must furnish an initialization list
you are not required to initialize the array elements
all array elements default to zero values
your array will contain no elements