Deck 6: Functions
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
Play
Full screen (f)
Deck 6: Functions
1
When used as a parameter, a _ variable allows a function to access and modify the original argument passed to it.
A)value
B)default value
C)reference
D)floating- point
E)static
A)value
B)default value
C)reference
D)floating- point
E)static
C
2
A function includes the statements that make up the function.
A)heading
B)parameter
C)prototype
D)definition
E)call
A)heading
B)parameter
C)prototype
D)definition
E)call
D
3
In a function prototype, in addition to the name of the function, you are required to furnish
A)the data type of the return value.
B)an identifier name for each parameter.
C)a data type for each parameter.
D)all of the above.
E)A and C, but not B.
A)the data type of the return value.
B)an identifier name for each parameter.
C)a data type for each parameter.
D)all of the above.
E)A and C, but not B.
E
4
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)test function
B)void function
C)stub
D)driver
E)prototype function
A)test function
B)void function
C)stub
D)driver
E)prototype function
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
A function can have parameters, and it can have either zero or one return value(s).
A)either one or two
B)a maximum of ten
C)zero to many
D)either zero or one
E)no
A)either one or two
B)a maximum of ten
C)zero to many
D)either zero or one
E)no
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
A variable is defined inside the body of a function and is not accessible outside that function.
A)constant
B)counter
C)global
D)reference
E)local
A)constant
B)counter
C)global
D)reference
E)local
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
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.
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
8
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)an integer.
B)passed into a reference parameter.
C)a static variable.
D)a constant.
E)passed by value.
A)an integer.
B)passed into a reference parameter.
C)a static variable.
D)a constant.
E)passed by value.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
Functions are ideal for use in menu- drive programs. When a user selects a menu item, the program can an appropriate function to carry out the user's choice.
A)return
B)call
C)define
D)declare
E)randomly select
A)return
B)call
C)define
D)declare
E)randomly select
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
A function is a statement that causes a function to execute.
A)call
B)parameter list
C)prototype
D)definition
E)header
A)call
B)parameter list
C)prototype
D)definition
E)header
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
A void function is one that
A)has no parameters.
B)returns no value.
C)is never called.
D)returns a zero.
E)has an empty function body.
A)has no parameters.
B)returns no value.
C)is never called.
D)returns a zero.
E)has an empty function body.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
A _ variable is declared outside all functions.
A)local
B)global
C)static
D)constant
E)counter
A)local
B)global
C)static
D)constant
E)counter
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
A(n)argument is one that is automatically passed to a parameter when the argument is left out of the function call.
A)default
B)null
C)actual
D)static
E)floating- point
A)default
B)null
C)actual
D)static
E)floating- point
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
When more than one function has the same name they are called functions.
A)renamed
B)sister
C)identical
D)overloaded
E)parallel
A)renamed
B)sister
C)identical
D)overloaded
E)parallel
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
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.
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
16
In the statement cout << sqrt(22.0);
1. is
A)an argument.
B)a memory location.
C)a default value.
D)a parameter.
E)an lvalue.
1. is
A)an argument.
B)a memory location.
C)a default value.
D)a parameter.
E)an lvalue.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
A _
A)stub is a program module whose purpose is to test other modules by calling them.
B)dummy program
C)pseudocode routine
D)main function
E)driver
A)stub is a program module whose purpose is to test other modules by calling them.
B)dummy program
C)pseudocode routine
D)main function
E)driver
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
A static local variable is one
A)whose value is retained between function calls.
B)whose value never changes.
C)that is reinitialized each time the function it is defined in is called.
D)with the same name as a global variable.
E)whose scope is limited to the function it is defined in.
A)whose value is retained between function calls.
B)whose value never changes.
C)that is reinitialized each time the function it is defined in is called.
D)with the same name as a global variable.
E)whose scope is limited to the function it is defined in.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
In C++ numeric global variables are by default and numeric local variables are by default.
A)initialized to zero, not initialized
B)initialized to zero, initialized to zero
C)not initialized, initialized to zero
D)not initialized, not initialized
E)None of the above
A)initialized to zero, not initialized
B)initialized to zero, initialized to zero
C)not initialized, initialized to zero
D)not initialized, not initialized
E)None of the above
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
A function function.
A)header
B)argument
C)that is void
D)parameter
E)prototype
A)header
B)argument
C)that is void
D)parameter
E)prototype
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Breaking a program up into a set of manageable sized functions is called programming.
A)low- level
B)functional
C)modular
D)high- level
E)divisible
A)low- level
B)functional
C)modular
D)high- level
E)divisible
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
A void function is one that
A)has an empty function body.
B)returns a zero or null character.
C)does nothing useful.
D)returns no value.
E)has no parameters.
A)has an empty function body.
B)returns a zero or null character.
C)does nothing useful.
D)returns no value.
E)has no parameters.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
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
24
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)return
B)break
C)end
D)exit
E)continue
A)return
B)break
C)end
D)exit
E)continue
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
It is possible for a function to have some parameters with default arguments and some without.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
Two or more functions may have the same name provided that
A)one has a prototype and the other doesn't.
B)they do different things.
C)their parameter lists are different.
D)their return types are different.
E)either C or D is true.
A)one has a prototype and the other doesn't.
B)they do different things.
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
27
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
28
A function can have zero to many parameters, and it can have return value(s).
A)either one or two
B)either zero or one
C)zero to many
D)no
E)a maximum of ten
A)either one or two
B)either zero or one
C)zero to many
D)no
E)a maximum of ten
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
When only a copy of an argument is passed to a function, it is said to be passed
A)by default value.
B)by copy.
C)informally.
D)by value.
E)by reference.
A)by default value.
B)by copy.
C)informally.
D)by value.
E)by reference.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
An overloaded function is one
A)that attempts to do too much in a single function.
B)that has too many parameters.
C)that call other functions.
D)that does different things depending on who calls it.
E)that has the same name as another function.
A)that attempts to do too much in a single function.
B)that has too many parameters.
C)that call other functions.
D)that does different things depending on who calls it.
E)that has the same name as another function.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
The value in local variable is retained between function calls.
A)an internal
B)a dynamic
C)a global
D)a static
E)no
A)an internal
B)a dynamic
C)a global
D)a static
E)no
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
A(n)is information that is passed to a function, and a(n)is a special variable that receives and holds that information.
A)parameter, argument
B)formal argument, actual argument
C)function prototype, function header
D)argument, parameter
E)function call, function header
A)parameter, argument
B)formal argument, actual argument
C)function prototype, function header
D)argument, parameter
E)function call, function header
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
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
34
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
35
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.
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
36
When a function just needs to use a copy of an argument passed to it, the argument should normally be passed
A)by value.
B)as a default argument.
C)by reference.
D)as a string.
E)by variable.
A)by value.
B)as a default argument.
C)by reference.
D)as a string.
E)by variable.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
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
38
The function causes the entire program to terminate, regardless of which function or control mechanism is executing.
A)continue()
B)exit()
C)break()
D)return()
E)terminate()
A)continue()
B)exit()
C)break()
D)return()
E)terminate()
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
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
40
A function other than the main function is executed
A)only once.
B)whenever it is called.
C)when the main function finishes executing.
D)when it is first defined.
E)when its function prototype is encountered.
A)only once.
B)whenever it is called.
C)when the main function finishes executing.
D)when it is first defined.
E)when its function prototype is encountered.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck