Deck 6: Modularity Using 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
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/50
Play
Full screen (f)
Deck 6: Modularity Using Functions
1
____ are any set of conditions a function requires to be true if it s to operate correctly.
A) Postconditions
B) Preconditions
C) Sentinels
D) Prototypes
A) Postconditions
B) Preconditions
C) Sentinels
D) Prototypes
B
2
Calling a function places a certain amount of overhead on a computer.
True
3
The names in parentheses in the header are called the formal ____ of the function.
A) parameters
B) variables
C) identifiers
D) constants
A) parameters
B) variables
C) identifiers
D) constants
A
4
The declaration statement for a function is referred to as a function ____.
A) prototype
B) calling
C) definition
D) initialization
A) prototype
B) calling
C) definition
D) initialization
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Declaration statements containing the word extern create new storage areas.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
A ____ is the beginning of a final function that can be used as a placeholder for the final unit until the unit is completed.
A) declaration
B) definition
C) stub
D) prototype
A) declaration
B) definition
C) stub
D) prototype
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
C++ provides the capability of using the same function name for more than one function, referred to as function ____.
A) prototyping
B) conditioning
C) interpreting
D) overloading
A) prototyping
B) conditioning
C) interpreting
D) overloading
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
In creating C++ functions, you must be concerned with the function itself and how it interacts with other functions, such as main() .
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
A function ____ is a single, complete function that serves as a model for a family of functions.
A) template
B) stub
C) prototype
D) definition
A) template
B) stub
C) prototype
D) definition
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
Static variables can be initialized using other variables.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
After they re created, local static variables remain in existence for the program s lifetime.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The function that does the calling is referred to as the ____ function.
A) summoned
B) child
C) called
D) calling
A) summoned
B) child
C) called
D) calling
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
In C++, nesting of functions is never permitted.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
Calling a function and passing arguments by value is a distinct advantage of C++.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
You should make all your variables global if possible.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
In C++, a function is allowed to change the contents of variables declared in other functions.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
C++ functions are constructed to be independent modules.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
Every C++ function consists of two parts, a function header and a function ____.
A) prototype
B) definition
C) body
D) declaration
A) prototype
B) definition
C) body
D) declaration
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
The line template , called a ____, is used to inform the compiler that the function immediately following is a template using a data type named T .
A) template prototype
B) template body
C) template prefix
D) template postfix
A) template prototype
B) template body
C) template prefix
D) template postfix
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
When a value is passed to a called function with only copies of the values contained in the arguments at the time of the call, the passed argument is referred to as a ____.
A) pass by reference
B) call by value
C) call by reference
D) passed by value
A) pass by reference
B) call by value
C) call by reference
D) passed by value
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
In C++ a reference parameter is declared with the syntax:
A) dataType referenceName
B) dataType* referenceName
C) dataType* referenceName
D) dataType referenceName
A) dataType referenceName
B) dataType* referenceName
C) dataType* referenceName
D) dataType referenceName
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
A function returning a value must specify the ____________________ type of the value to be returned.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
In a function call, the items enclosed in parentheses are known as ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Passing addresses is referred to as a function ____.
A) pass by value
B) pass by reference
C) call by value
D) pass by copy
A) pass by value
B) pass by reference
C) call by value
D) pass by copy
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
____ is the section of the program where the identifier, such as a variable, is valid or known.
A) Reach
B) Spread
C) Range
D) Scope
A) Reach
B) Spread
C) Range
D) Scope
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
In C++, function prototypes typically have ____ scope.
A) external
B) local
C) internal
D) global
A) external
B) local
C) internal
D) global
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
Because the variables created in a function are conventionally available only to the function, they are said to be ____ variables.
A) local
B) global
C) external
D) internal
A) local
B) global
C) external
D) internal
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
The default in C++ is to make passes by ____.
A) address
B) pointer
C) value
D) reference
A) address
B) pointer
C) value
D) reference
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
In addition to argument data types, ____________________ argument values may be assigned in the function prototype for added flexibility.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
A local variable that is declared as ____ causes the program to keep the variable and its latest value even when the function that declared it is through executing.
A) auto
B) static
C) register
D) extern
A) auto
B) static
C) register
D) extern
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
The use of function ____________________ permits the compiler to error-check data types.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Where and how long a variable s storage locations are kept before they re released can be determined by the variable s ____.
A) data type
B) name
C) storage category
D) scope
A) data type
B) name
C) storage category
D) scope
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Telling the C++ compiler that a function is ____ causes a copy of the function code to be placed in the program at the point the function is called.
A) inline
B) online
C) overloaded
D) overline
A) inline
B) online
C) overloaded
D) overline
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
The symbol ____ represents the C++ s scope resolution operator.
A) ::
B) :
C) ||
D) ;;
A) ::
B) :
C) ||
D) ;;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Most computers have a few high-speed storage areas called ____.
A) registers
B) static
C) CPU memory
D) external memory
A) registers
B) static
C) CPU memory
D) external memory
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Local variables can be members only of the auto , static , or ____ storage categories.
A) global
B) const
C) extern
D) register
A) global
B) const
C) extern
D) register
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
A(n) ____________________ function is summoned into action by the calling function.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
A variable with ____ scope has storage created for it by a declaration statement located outside any function.
A) local
B) global
C) internal
D) function
A) local
B) global
C) internal
D) function
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
A function returning a value must specify, in its ____, the data type of the value to be returned.
A) body
B) initialization
C) assignment
D) header
A) body
B) initialization
C) assignment
D) header
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
A(n) ____ declaration statement simply informs the computer that a global variable already exists and can now be used.
A) auto
B) static
C) extern
D) global
A) auto
B) static
C) extern
D) global
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
Initialization of ____________________ variables is done only once, when the program is first compiled.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Function call overhead is justified because it can reduce a program s ____________________ substantially.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
To actually use a returned value, you must provide a(n) ____________________ to store the value or to use the value in an expression.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
In addition to the space dimension represented by scope, variables have a(n) ____________________ dimension.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
A variable is said to be alive if ____________________ for the variable is available.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
C++ provides two types of address parameters: ____________________ and pointers.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
The advantage of using an inline ____________________ is an increase in execution speed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Variables that are created by definition statements external to a function are called ____________________ variables.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
After a function returns a value, program control reverts to the ____________________ function.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
While a function is executing, only variables and parameters that are in the ____________________ for that function can be accessed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck