Deck 6: Using C++ Functions

Full screen (f)
exit full mode
Question
When you declare a pointer, you insert a(n) ____ in front of the variable name.

A) ampersand
B) asterisk
C) pipe
D) pound sign
Use Space or
up arrow
down arrow
to flip the card.
Question
The ____ of a variable defines where it can be accessed in a program.

A) abstraction
B) scope
C) encapsulation
D) lifetime
Question
The ____ of a variable is the time during which it is defined-from declaration to destruction.

A) scope
B) duration
C) encapsulation
D) lifetime
Question
The statement return letter; can be alternatively written as ____. Both statements work identically.

A) return(letter);
B) return:letter;
C) return{letter};
D) return[letter];
Question
A function declaration is also called a function ____.

A) statement
B) scope
C) call
D) prototype
Question
The statement that executes a function is the function ____.

A) statement
B) alias
C) call
D) expression
Question
____ variables are those that are known to all functions in a program.

A) Global
B) Local
C) General
D) Modular
Question
____ variables are known only in a limited scope.

A) Global
B) Local
C) Limited
D) Modular
Question
Statements that can never execute are called dead code.
Question
____ is also called data hiding.

A) Overloading
B) Overriding
C) Abstraction
D) Encapsulation
Question
A(n) ____ is an alternative name.

A) alias
B) prototype
C) call
D) parameter
Question
Encapsulation simplifies your concept of the process or object, allowing you to ignore nonessential details.
Question
Any variable listed in a function header is known as a(n) ____ parameter.

A) declaration
B) actual
C) formal
D) prototype
Question
An array name is a constant pointer, meaning you cannot alter its contents.
Question
A(n) ____ is the expression used within the parentheses when you call a function.

A) value
B) argument
C) input
D) prototype
Question
Most compilers will issue an error message if a function receives a variable as a constant but then passes the variable to another function that does not receive the variable as a constant.
Question
Maintenance programming involves making modifications and improvements to existing systems.
Question
A(n) ____ value is a value sent from a subfunction to the function that called it.

A) return
B) output
C) subroutine
D) function
Question
An argument used in a function call is known as a(n) ____ parameter.

A) execution
B) actual
C) formal
D) call
Question
The scope resolution operator (____) allows you to refer to a global variable when a local one has taken precedence.

A) *
B) &
C) ::
D) !
Question
What are some errors typically made by beginning programmers when they declare, call, and write functions?
Question
____________________ helps readers of program code understand the purpose of the code.
Question
When is a variable in scope or out of scope?
Question
When you want to use a value stored in a pointer, you must use the ____ to dereference the pointer, or use the value to which it points.

A) ampersand
B) asterisk
C) pipe
D) bang
Question
What are the disadvantages of using global variables instead of local variables?
Question
To "____________________" means to take precedence over.
Question
Where in your program should you place include statements?
Question
Describe two benefits of using structures with functions (either as arguments or a return type)?
Question
The principle of ____ is a programming principle that says you should give a process only the authority it needs to accomplish its job.

A) least privilege
B) abstraction
C) encapsulation
D) overloading
Question
An array name is a(n) ____________________; it holds a memory address.
Question
The type of object or variable that a function returns to the function that calls it is the function's ____________________.
Question
When you use a(n) ____ function, a copy of the function statements is placed directly into the compiled calling program.

A) inline
B) local
C) global
D) prototype
Question
____ a function name involves creating multiple functions with the same name but different parameter lists.

A) Encapsulating
B) Prototyping
C) Overriding
D) Overloading
Question
A(n) ____ parameter to a function is one for which an automatic value is supplied if you do not explicitly use one.

A) implicit
B) default
C) local
D) global
Question
In different programming languages, the counterpart to a function is known as a subroutine, procedure, or ____________________.
Question
Write an example of code that illustrates how to use the scope resolution operator.
Question
What are the benefits that you gain when you write functions that you include in other programs?
Question
A(n) ____________________ copy of an object is one in which the value of each field or member of the object is copied to its counterpart in another object.
Question
A variable that acts as an alias for another variable is called a ____ variable.

A) least privilege
B) copy
C) reference
D) local
Question
List some advantages and disadvantages of passing an address of a variable to a function.
Question
Match between columns
situation in which the compiler cannot tell which version of a function to use
black box
situation in which the compiler cannot tell which version of a function to use
function
situation in which the compiler cannot tell which version of a function to use
overhead
situation in which the compiler cannot tell which version of a function to use
function prototype
situation in which the compiler cannot tell which version of a function to use
ambiguity
situation in which the compiler cannot tell which version of a function to use
subfunction
situation in which the compiler cannot tell which version of a function to use
encapsulation
situation in which the compiler cannot tell which version of a function to use
abstraction
situation in which the compiler cannot tell which version of a function to use
inline function
Question
Match between columns
small function with no overhead because program control never transfers to the function
black box
small function with no overhead because program control never transfers to the function
function
small function with no overhead because program control never transfers to the function
overhead
small function with no overhead because program control never transfers to the function
function prototype
small function with no overhead because program control never transfers to the function
ambiguity
small function with no overhead because program control never transfers to the function
subfunction
small function with no overhead because program control never transfers to the function
encapsulation
small function with no overhead because program control never transfers to the function
abstraction
small function with no overhead because program control never transfers to the function
inline function
Question
Match between columns
cost of doing business involved in calling a function
black box
cost of doing business involved in calling a function
function
cost of doing business involved in calling a function
overhead
cost of doing business involved in calling a function
function prototype
cost of doing business involved in calling a function
ambiguity
cost of doing business involved in calling a function
subfunction
cost of doing business involved in calling a function
encapsulation
cost of doing business involved in calling a function
abstraction
cost of doing business involved in calling a function
inline function
Question
Match between columns
principle of containing variables locally in their functions
black box
principle of containing variables locally in their functions
function
principle of containing variables locally in their functions
overhead
principle of containing variables locally in their functions
function prototype
principle of containing variables locally in their functions
ambiguity
principle of containing variables locally in their functions
subfunction
principle of containing variables locally in their functions
encapsulation
principle of containing variables locally in their functions
abstraction
principle of containing variables locally in their functions
inline function
Question
Match between columns
process of extracting the relevant attributes of a process or object
black box
process of extracting the relevant attributes of a process or object
function
process of extracting the relevant attributes of a process or object
overhead
process of extracting the relevant attributes of a process or object
function prototype
process of extracting the relevant attributes of a process or object
ambiguity
process of extracting the relevant attributes of a process or object
subfunction
process of extracting the relevant attributes of a process or object
encapsulation
process of extracting the relevant attributes of a process or object
abstraction
process of extracting the relevant attributes of a process or object
inline function
Question
Match between columns
statement that notifies the calling function that the definition (details) of the named function will come later
black box
statement that notifies the calling function that the definition (details) of the named function will come later
function
statement that notifies the calling function that the definition (details) of the named function will come later
overhead
statement that notifies the calling function that the definition (details) of the named function will come later
function prototype
statement that notifies the calling function that the definition (details) of the named function will come later
ambiguity
statement that notifies the calling function that the definition (details) of the named function will come later
subfunction
statement that notifies the calling function that the definition (details) of the named function will come later
encapsulation
statement that notifies the calling function that the definition (details) of the named function will come later
abstraction
statement that notifies the calling function that the definition (details) of the named function will come later
inline function
Question
Match between columns
function used by a main() function
black box
function used by a main() function
function
function used by a main() function
overhead
function used by a main() function
function prototype
function used by a main() function
ambiguity
function used by a main() function
subfunction
function used by a main() function
encapsulation
function used by a main() function
abstraction
function used by a main() function
inline function
Question
What is name mangling?
Question
Match between columns
device that you cannot look into to discover how it works but that works nonetheless
black box
device that you cannot look into to discover how it works but that works nonetheless
function
device that you cannot look into to discover how it works but that works nonetheless
overhead
device that you cannot look into to discover how it works but that works nonetheless
function prototype
device that you cannot look into to discover how it works but that works nonetheless
ambiguity
device that you cannot look into to discover how it works but that works nonetheless
subfunction
device that you cannot look into to discover how it works but that works nonetheless
encapsulation
device that you cannot look into to discover how it works but that works nonetheless
abstraction
device that you cannot look into to discover how it works but that works nonetheless
inline function
Question
When should you use an inline function?
Question
Match between columns
module that performs a task or group of tasks
black box
module that performs a task or group of tasks
function
module that performs a task or group of tasks
overhead
module that performs a task or group of tasks
function prototype
module that performs a task or group of tasks
ambiguity
module that performs a task or group of tasks
subfunction
module that performs a task or group of tasks
encapsulation
module that performs a task or group of tasks
abstraction
module that performs a task or group of tasks
inline function
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/51
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Using C++ Functions
1
When you declare a pointer, you insert a(n) ____ in front of the variable name.

A) ampersand
B) asterisk
C) pipe
D) pound sign
B
2
The ____ of a variable defines where it can be accessed in a program.

A) abstraction
B) scope
C) encapsulation
D) lifetime
B
3
The ____ of a variable is the time during which it is defined-from declaration to destruction.

A) scope
B) duration
C) encapsulation
D) lifetime
D
4
The statement return letter; can be alternatively written as ____. Both statements work identically.

A) return(letter);
B) return:letter;
C) return{letter};
D) return[letter];
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
5
A function declaration is also called a function ____.

A) statement
B) scope
C) call
D) prototype
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
6
The statement that executes a function is the function ____.

A) statement
B) alias
C) call
D) expression
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
7
____ variables are those that are known to all functions in a program.

A) Global
B) Local
C) General
D) Modular
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
8
____ variables are known only in a limited scope.

A) Global
B) Local
C) Limited
D) Modular
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
9
Statements that can never execute are called dead code.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
10
____ is also called data hiding.

A) Overloading
B) Overriding
C) Abstraction
D) Encapsulation
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
11
A(n) ____ is an alternative name.

A) alias
B) prototype
C) call
D) parameter
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
12
Encapsulation simplifies your concept of the process or object, allowing you to ignore nonessential details.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
13
Any variable listed in a function header is known as a(n) ____ parameter.

A) declaration
B) actual
C) formal
D) prototype
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
14
An array name is a constant pointer, meaning you cannot alter its contents.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
15
A(n) ____ is the expression used within the parentheses when you call a function.

A) value
B) argument
C) input
D) prototype
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
16
Most compilers will issue an error message if a function receives a variable as a constant but then passes the variable to another function that does not receive the variable as a constant.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
17
Maintenance programming involves making modifications and improvements to existing systems.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
18
A(n) ____ value is a value sent from a subfunction to the function that called it.

A) return
B) output
C) subroutine
D) function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
19
An argument used in a function call is known as a(n) ____ parameter.

A) execution
B) actual
C) formal
D) call
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
20
The scope resolution operator (____) allows you to refer to a global variable when a local one has taken precedence.

A) *
B) &
C) ::
D) !
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
21
What are some errors typically made by beginning programmers when they declare, call, and write functions?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
22
____________________ helps readers of program code understand the purpose of the code.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
23
When is a variable in scope or out of scope?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
24
When you want to use a value stored in a pointer, you must use the ____ to dereference the pointer, or use the value to which it points.

A) ampersand
B) asterisk
C) pipe
D) bang
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
25
What are the disadvantages of using global variables instead of local variables?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
26
To "____________________" means to take precedence over.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
27
Where in your program should you place include statements?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
28
Describe two benefits of using structures with functions (either as arguments or a return type)?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
29
The principle of ____ is a programming principle that says you should give a process only the authority it needs to accomplish its job.

A) least privilege
B) abstraction
C) encapsulation
D) overloading
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
30
An array name is a(n) ____________________; it holds a memory address.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
31
The type of object or variable that a function returns to the function that calls it is the function's ____________________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
32
When you use a(n) ____ function, a copy of the function statements is placed directly into the compiled calling program.

A) inline
B) local
C) global
D) prototype
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
33
____ a function name involves creating multiple functions with the same name but different parameter lists.

A) Encapsulating
B) Prototyping
C) Overriding
D) Overloading
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
34
A(n) ____ parameter to a function is one for which an automatic value is supplied if you do not explicitly use one.

A) implicit
B) default
C) local
D) global
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
35
In different programming languages, the counterpart to a function is known as a subroutine, procedure, or ____________________.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
36
Write an example of code that illustrates how to use the scope resolution operator.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
37
What are the benefits that you gain when you write functions that you include in other programs?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
38
A(n) ____________________ copy of an object is one in which the value of each field or member of the object is copied to its counterpart in another object.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
39
A variable that acts as an alias for another variable is called a ____ variable.

A) least privilege
B) copy
C) reference
D) local
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
40
List some advantages and disadvantages of passing an address of a variable to a function.
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
situation in which the compiler cannot tell which version of a function to use
black box
situation in which the compiler cannot tell which version of a function to use
function
situation in which the compiler cannot tell which version of a function to use
overhead
situation in which the compiler cannot tell which version of a function to use
function prototype
situation in which the compiler cannot tell which version of a function to use
ambiguity
situation in which the compiler cannot tell which version of a function to use
subfunction
situation in which the compiler cannot tell which version of a function to use
encapsulation
situation in which the compiler cannot tell which version of a function to use
abstraction
situation in which the compiler cannot tell which version of a function to use
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
42
Match between columns
small function with no overhead because program control never transfers to the function
black box
small function with no overhead because program control never transfers to the function
function
small function with no overhead because program control never transfers to the function
overhead
small function with no overhead because program control never transfers to the function
function prototype
small function with no overhead because program control never transfers to the function
ambiguity
small function with no overhead because program control never transfers to the function
subfunction
small function with no overhead because program control never transfers to the function
encapsulation
small function with no overhead because program control never transfers to the function
abstraction
small function with no overhead because program control never transfers to the function
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
43
Match between columns
cost of doing business involved in calling a function
black box
cost of doing business involved in calling a function
function
cost of doing business involved in calling a function
overhead
cost of doing business involved in calling a function
function prototype
cost of doing business involved in calling a function
ambiguity
cost of doing business involved in calling a function
subfunction
cost of doing business involved in calling a function
encapsulation
cost of doing business involved in calling a function
abstraction
cost of doing business involved in calling a function
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
44
Match between columns
principle of containing variables locally in their functions
black box
principle of containing variables locally in their functions
function
principle of containing variables locally in their functions
overhead
principle of containing variables locally in their functions
function prototype
principle of containing variables locally in their functions
ambiguity
principle of containing variables locally in their functions
subfunction
principle of containing variables locally in their functions
encapsulation
principle of containing variables locally in their functions
abstraction
principle of containing variables locally in their functions
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
45
Match between columns
process of extracting the relevant attributes of a process or object
black box
process of extracting the relevant attributes of a process or object
function
process of extracting the relevant attributes of a process or object
overhead
process of extracting the relevant attributes of a process or object
function prototype
process of extracting the relevant attributes of a process or object
ambiguity
process of extracting the relevant attributes of a process or object
subfunction
process of extracting the relevant attributes of a process or object
encapsulation
process of extracting the relevant attributes of a process or object
abstraction
process of extracting the relevant attributes of a process or object
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
46
Match between columns
statement that notifies the calling function that the definition (details) of the named function will come later
black box
statement that notifies the calling function that the definition (details) of the named function will come later
function
statement that notifies the calling function that the definition (details) of the named function will come later
overhead
statement that notifies the calling function that the definition (details) of the named function will come later
function prototype
statement that notifies the calling function that the definition (details) of the named function will come later
ambiguity
statement that notifies the calling function that the definition (details) of the named function will come later
subfunction
statement that notifies the calling function that the definition (details) of the named function will come later
encapsulation
statement that notifies the calling function that the definition (details) of the named function will come later
abstraction
statement that notifies the calling function that the definition (details) of the named function will come later
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
function used by a main() function
black box
function used by a main() function
function
function used by a main() function
overhead
function used by a main() function
function prototype
function used by a main() function
ambiguity
function used by a main() function
subfunction
function used by a main() function
encapsulation
function used by a main() function
abstraction
function used by a main() function
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
48
What is name mangling?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
device that you cannot look into to discover how it works but that works nonetheless
black box
device that you cannot look into to discover how it works but that works nonetheless
function
device that you cannot look into to discover how it works but that works nonetheless
overhead
device that you cannot look into to discover how it works but that works nonetheless
function prototype
device that you cannot look into to discover how it works but that works nonetheless
ambiguity
device that you cannot look into to discover how it works but that works nonetheless
subfunction
device that you cannot look into to discover how it works but that works nonetheless
encapsulation
device that you cannot look into to discover how it works but that works nonetheless
abstraction
device that you cannot look into to discover how it works but that works nonetheless
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
50
When should you use an inline function?
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
51
Match between columns
module that performs a task or group of tasks
black box
module that performs a task or group of tasks
function
module that performs a task or group of tasks
overhead
module that performs a task or group of tasks
function prototype
module that performs a task or group of tasks
ambiguity
module that performs a task or group of tasks
subfunction
module that performs a task or group of tasks
encapsulation
module that performs a task or group of tasks
abstraction
module that performs a task or group of tasks
inline function
Unlock Deck
Unlock for access to all 51 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 51 flashcards in this deck.