C++ CH 6

25 July 2022
4.7 (114 reviews)
43 test answers

Unlock all answers in this set

Unlock answers (39)
question
concept.
answer
concept. A program may be broken up into manageable functions.
question
function
answer
A _____ is a collection of statements that performs a specific task.
question
concept.
answer
concept. A function call is a statement that causes a function to execute. A function definition contains the statements that make up the function.
question
return type
answer
A function can send a value to the part of the program that executed it. The return type is the data type of the value that is sent from the function.
question
Name
answer
You should give each function a descriptive name. In general, the same rules that apply to variable names also apply to function names.
question
Parameter list
answer
The program can send data into a function. The parameter list is a list of variables that hold the values being passed into the function
question
function header
answer
the line in the definition that reads int main ( ) is called the function header.
question
void functions
answer
Some functions simply perform one or more statements, which follows terminate. These are called _____.
question
return type, name, parameter list
answer
The function header declares the function's _____ _____ and _____.
question
function prototype
answer
a _____ eliminates the need to place a function definition before all calls to the function.
question
note.
answer
note. function prototypes are also known as function declarations.
question
warning
answer
warning. you must place either the function definition or the function prototype ahead of all calls to that function.
question
concept.
answer
concept. When a function is called, the program may send values into the function. these values are called arguments.
question
parameter
answer
A _____ is a special variable that holds a value being passed into a function.
question
note.
answer
note. the function prototype must list the data type of each parameter.
question
concept.
answer
concept. When an argument is passed into a parameter , only a copy of the argument's value is passed. Changes to the parameter do not affect the original argument.
question
passed by value
answer
when only a copy of an argument is passed to a function, it is said to be _____.
question
concept.
answer
concept. Functions are ideal for use in menu-driven programs. When the user selects an item from a menu, the program can call the appropriate function.
question
modular
answer
A _____ program is broken up into functions that perform specific tasks.
question
return
answer
the _____ statement causes a function to end immediately.
question
concept.
answer
concept. A function may send a value back to the part of the program that called the function.
question
value returning function
answer
A _____ is a function that returns a value. the pow function is an example.
question
local variables
answer
variables that are defined inside a function are called _____.
question
concept.
answer
concept. Functions may return true or false values.
question
concept.
answer
concept. A local variable is defined inside a function and is not accessible outside the function. A global variable is defined outside all functions and is accessible to all functions in its scope.
question
lifetime
answer
A function's local variables exist only while the function is executing. This is known as the _____ of a local variable.
question
global constant
answer
a _____ is a named constant that is available to every function in a program.
question
static local variable
answer
A variable that can be stored after a function is done. 'static int num' is an example.
question
concept.
answer
concept. Default arguments are passed into parameters automatically if no argument is provided in the function call.
question
note.
answer
note. parameters with default arguments must be defined last.
question
concept.
answer
concept. When used as parameters, reference variables allow a function to access the parameter's original argument. Changes to the parameter are also made to the argument.
question
reference variable
answer
A _____ is an alias for another variable. Any changes made to the reference variable are actually performed on the variable for which it is an alias.
question
note.
answer
note. reference variable ex: void doubleNum(int &refVar) { refVar *= 2; } note: The variable refVar is called "a reference to an int ."
question
note.
answer
note. When a program works with a reference variable, it is actually working with the variable it references, or points to.
question
passed by reference
answer
When a reference parameter is used, it is said that the argument is _____.
question
warning.
answer
WARNING! Don't get carried away with using reference variables as function parameters. Any time you allow a function to alter a variable that's outside the function, you are creating potential debugging problems. Reference variables should only be used as parameters when the situation requires them.
question
concept.
answer
concept. two or more functions may have the same name, as long as their parameter lists are different.
question
function signature
answer
The _____ is the name of the function and the data types of the function's parameters in the proper order.
question
concept.
answer
concept. The exit( ) function causes a program to terminate, regardless of which function or control mechanism is executing.
question
note.
answer
note. the exit function requires the cstdlib header file.
question
stubs drivers
answer
_____ and _____ are very helpful tools for testing and debugging programs that use functions. They allow you to test the individual functions in a program, in isolation from the parts of the program that call the functions.
question
stub
answer
A _____ is a dummy function that is called instead of the actual function it represents. It usually displays a test message acknowledging that it was called, and nothing more.
question
driver
answer
A _____ is a program that tests a function by simply calling it. If the function accepts arguments, the driver passes test data. If the function returns a value, the driver displays the return value on the screen.