Deck 6: Functions

Full screen (f)
exit full mode
Question
It is possible for a function to have some parameters with default arguments and some without.
Use Space or
up arrow
down arrow
to flip the card.
Question
The ________ statement causes a function to end and the flow of control to move back to the point where the function call was made.

A) end
B) break
C) continue
D) return
E) exit
Question
Functions are ideal for use in menu-drive programs. When a user selects a menu item, the program can call an appropriate function to carry out the user's choice.
Question
When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.
Question
A ________ variable is defined inside the body of a function and is not accessible outside that function.

A) global
B) reference
C) local
D) counter
E) constant
Question
A ________ is a program module whose purpose is to test other modules by calling them.

A) stub
B) driver
C) main function
D) dummy program
E) pseudocode routine
Question
A function ________ includes the statements that make up the function.

A) definition
B) prototype
C) call
D) heading
E) parameter
Question
In a function call, in addition to the name of the function, you are required to furnish

A) a data type for each argument.
B) an identifier name or constant for each argument.
C) the data type of the return value.
D) All of the above
E) A, and B, but not C.
Question
A function with a return type of bool must return a value of either True or false.
Question
The value in ________ local variable is retained between function calls.

A) a global
B) an internal
C) a static
D) a dynamic
E) no
Question
When used as a parameter, a ________ variable allows a function to access and modify the original argument passed to it.

A) static
B) value
C) reference
D) floating-point
E) default value
Question
A function other than the main function is executed

A) when it is first defined.
B) when its function prototype is encountered.
C) only once.
D) when the main function finishes executing.
E) whenever it is called.
Question
A void function is one that

A) does nothing useful.
B) has an empty function body.
C) has no parameters.
D) returns no value.
E) returns a zero or null character.
Question
Two or more functions may have the same name provided that

A) they do different things.
B) one has a prototype and the other doesn't.
C) their parameter lists are different.
D) their return types are different.
E) either C or D is True.
Question
The ________ function causes the entire program to terminate, regardless of which function or control mechanism is executing.

A) terminate()
B) return()
C) continue()
D) exit()
E) break()
Question
A function can have zero to many parameters and either zero or one return value(s).
Question
In a function prototype, in addition to the name of the function, you are required to furnish

A) a data type for each parameter.
B) an identifier name for each parameter.
C) the data type of the return value.
D) all of the above.
E) A and C, but not B.
Question
When more than one function has the same name they are called ________ functions.

A) overloaded
B) renamed
C) parallel
D) identical
E) sister
Question
In a function header, in addition to the name of the function, you are required to furnish

A) a data type for each parameter.
B) an identifier name for each parameter.
C) the data type of the return value.
D) all of the above.
E) B and C, but not A.
Question
Breaking a program up into a set of manageable sized functions is called ________ programming.

A) functional
B) modular
C) divisible
D) high-level
E) low-level
Question
When you make a function call, the order of the arguments you send does not matter as long as the number of arguments matches the number of parameters the function has.
Question
Both function headers and function calls must list the data types of all data being passed to the function.
Question
When a function needs access to an original argument passed to it, for example in order to change its value, the argument needs to be

A) passed by value.
B) passed into a reference parameter.
C) a static variable.
D) an integer.
E) a constant.
Question
A ________ is a dummy function that is called instead of the actual function it represents, to test that the call to and return from the function are working correctly.

A) stub
B) driver
C) test function
D) void function
E) prototype function
Question
A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information.

A) function call, function header
B) function prototype, function header
C) parameter, argument
D) argument, parameter
E) formal argument, actual argument
Question
Although global variables can be useful, it is considered good programming practice to restrict your use of them.
Question
An overloaded function is one

A) that calls other functions.
B) that has the same name as another function.
C) that has too many parameters.
D) that attempts to do too much in a single function.
E) that does different things depending on who calls it.
Question
When only a copy of an argument is passed to a function, it is said to be passed

A) by copy.
B) by reference.
C) informally.
D) by value.
E) by default value.
Question
A function can have ________ parameters, and it can have either zero or one return value(s).

A) zero to many
B) either zero or one
C) either one or two
D) a maximum of ten
E) no
Question
A function ________ is a statement that causes a function to execute.

A) prototype
B) header
C) definition
D) call
E) parameter list
Question
You may use the exit() function to return the flow of control from a function back to main() regardless of where the function was called from.
Question
In the following statement, what is 22.0?
Cout << sqrt(22.0);

A) A memory location.
B) A parameter.
C) An argument.
D) A default value.
E) An lvalue.
Question
In C++ global and local numeric variables are initialized to zero by default.
Question
A void function is one that

A) has an empty function body.
B) is never called.
C) returns no value.
D) has no parameters.
E) returns a zero.
Question
A function ________ eliminates the need to place the function definition before all calls to the function.

A) header
B) prototype
C) argument
D) parameter
E) that is void
Question
A(n) ________ argument is one that is automatically passed to a parameter when the argument is left out of the function call.

A) floating-point
B) actual
C) null
D) default
E) static
Question
A static local variable is one

A) whose value never changes.
B) whose value is retained between function calls.
C) with the same name as a global variable.
D) whose scope is limited to the function it is defined in.
E) that is reinitialized each time the function it is defined in is called.
Question
If a function has no return statement, the flow of control moves to the next function in the file when the closing brace of the function body is reached.
Question
A ________ variable is declared outside all functions.

A) local
B) global
C) static
D) counter
E) constant
Question
One reason for using functions is to break programs into a set of manageable units, or modules.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Functions
1
It is possible for a function to have some parameters with default arguments and some without.
True
2
The ________ statement causes a function to end and the flow of control to move back to the point where the function call was made.

A) end
B) break
C) continue
D) return
E) exit
D
3
Functions are ideal for use in menu-drive programs. When a user selects a menu item, the program can call an appropriate function to carry out the user's choice.
True
4
When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
A ________ variable is defined inside the body of a function and is not accessible outside that function.

A) global
B) reference
C) local
D) counter
E) constant
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
A ________ is a program module whose purpose is to test other modules by calling them.

A) stub
B) driver
C) main function
D) dummy program
E) pseudocode routine
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
A function ________ includes the statements that make up the function.

A) definition
B) prototype
C) call
D) heading
E) parameter
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
In a function call, in addition to the name of the function, you are required to furnish

A) a data type for each argument.
B) an identifier name or constant for each argument.
C) the data type of the return value.
D) All of the above
E) A, and B, but not C.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
A function with a return type of bool must return a value of either True or false.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
The value in ________ local variable is retained between function calls.

A) a global
B) an internal
C) a static
D) a dynamic
E) no
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
When used as a parameter, a ________ variable allows a function to access and modify the original argument passed to it.

A) static
B) value
C) reference
D) floating-point
E) default value
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
A function other than the main function is executed

A) when it is first defined.
B) when its function prototype is encountered.
C) only once.
D) when the main function finishes executing.
E) whenever it is called.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
A void function is one that

A) does nothing useful.
B) has an empty function body.
C) has no parameters.
D) returns no value.
E) returns a zero or null character.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
Two or more functions may have the same name provided that

A) they do different things.
B) one has a prototype and the other doesn't.
C) their parameter lists are different.
D) their return types are different.
E) either C or D is True.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
The ________ function causes the entire program to terminate, regardless of which function or control mechanism is executing.

A) terminate()
B) return()
C) continue()
D) exit()
E) break()
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
A function can have zero to many parameters and either zero or one return value(s).
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
In a function prototype, in addition to the name of the function, you are required to furnish

A) a data type for each parameter.
B) an identifier name for each parameter.
C) the data type of the return value.
D) all of the above.
E) A and C, but not B.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
When more than one function has the same name they are called ________ functions.

A) overloaded
B) renamed
C) parallel
D) identical
E) sister
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
In a function header, in addition to the name of the function, you are required to furnish

A) a data type for each parameter.
B) an identifier name for each parameter.
C) the data type of the return value.
D) all of the above.
E) B and C, but not A.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
Breaking a program up into a set of manageable sized functions is called ________ programming.

A) functional
B) modular
C) divisible
D) high-level
E) low-level
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
When you make a function call, the order of the arguments you send does not matter as long as the number of arguments matches the number of parameters the function has.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
Both function headers and function calls must list the data types of all data being passed to the function.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
When a function needs access to an original argument passed to it, for example in order to change its value, the argument needs to be

A) passed by value.
B) passed into a reference parameter.
C) a static variable.
D) an integer.
E) a constant.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
A ________ is a dummy function that is called instead of the actual function it represents, to test that the call to and return from the function are working correctly.

A) stub
B) driver
C) test function
D) void function
E) prototype function
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information.

A) function call, function header
B) function prototype, function header
C) parameter, argument
D) argument, parameter
E) formal argument, actual argument
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
Although global variables can be useful, it is considered good programming practice to restrict your use of them.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
An overloaded function is one

A) that calls other functions.
B) that has the same name as another function.
C) that has too many parameters.
D) that attempts to do too much in a single function.
E) that does different things depending on who calls it.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
When only a copy of an argument is passed to a function, it is said to be passed

A) by copy.
B) by reference.
C) informally.
D) by value.
E) by default value.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
A function can have ________ parameters, and it can have either zero or one return value(s).

A) zero to many
B) either zero or one
C) either one or two
D) a maximum of ten
E) no
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
A function ________ is a statement that causes a function to execute.

A) prototype
B) header
C) definition
D) call
E) parameter list
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
You may use the exit() function to return the flow of control from a function back to main() regardless of where the function was called from.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
In the following statement, what is 22.0?
Cout << sqrt(22.0);

A) A memory location.
B) A parameter.
C) An argument.
D) A default value.
E) An lvalue.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
In C++ global and local numeric variables are initialized to zero by default.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
A void function is one that

A) has an empty function body.
B) is never called.
C) returns no value.
D) has no parameters.
E) returns a zero.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
A function ________ eliminates the need to place the function definition before all calls to the function.

A) header
B) prototype
C) argument
D) parameter
E) that is void
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
A(n) ________ argument is one that is automatically passed to a parameter when the argument is left out of the function call.

A) floating-point
B) actual
C) null
D) default
E) static
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
A static local variable is one

A) whose value never changes.
B) whose value is retained between function calls.
C) with the same name as a global variable.
D) whose scope is limited to the function it is defined in.
E) that is reinitialized each time the function it is defined in is called.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
If a function has no return statement, the flow of control moves to the next function in the file when the closing brace of the function body is reached.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
A ________ variable is declared outside all functions.

A) local
B) global
C) static
D) counter
E) constant
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
One reason for using functions is to break programs into a set of manageable units, or modules.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.