C++ Exam 2
driver
A program that tests a function by simply calling it.
When writing functions that accept multi-dimensional arrays as arguments, ________________ must be explicitly stated in the parameter list. a. all dimensions b. all but the first dimension c. the size declarator of the first dimension d. all element values
all but the first dimension
values sent to a function are called
arguements
A(n) ________ is information that is passed to a function, and a(n) ________ is information that is received by a function. a. prototype, header b. parameter, argument c. argument, parameter d. function call, function header e. None of these
argument, parameter
Look at the following function prototype: int myFunction(double); What is the data type of the funtion's return value?
int
An array can store a group of values, but the values must be: a. the same data type b. each of a different data type c. constants d. integers
the same data type
________ functions may have the same name, as long as their parameter lists are different. a. Un-prototyped b. Two or more c. Zero d. Only two e. None of these
two or more
what is overloading functions?
two or more functions can have the same name as long as they have different parameter lists
reference variable in header
void doubleNum(int &refVar)
how to put array[12] in a function call?
function(array, SIZE);
A ____________ variable is declared outside all functions.
global
how to return a boolian value from a function
status = true; //or false return status;
What is the last legal subscript that can be used with an array that has the following declaration: int values[5] a. 0 b. 5 c. 4 d. 6
4
An array that will hold 5 names with 20 characters in the name would be declared using which statement? a. char names[5][20]; b. char names[20][5]; c. char names[21][5]; d. char names[5][21];
D
Which of the following is a valid C++ array definition? a. int array[0]; b. float $payments[10]; c. void numbers[5]; d. int array[10];
D
What does a function prototype do?
Eliminates the need to place a function definition before all calls to the function
int function(someVariable); What is someVariable? what is int?
a parameter, a return type
Subscript numbering in C++: a. can be set at runtime b. can begin with a programmer-defined value c. varies from program to program d. begins with zero
begins with zero
prototype example
bool verify(char);
Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function. a. prototype b. define c. declare d. call e. None of these
call
A function is executed when it is _____________.
called
Here is the header for a function named computeValue: void computeValue(int value) Which of the following is a valid call to the function?
computeValue(10);
What is a default arguement and how to create a prototype and call?
default is not using any variables as parameters, just use values. Prototype: void showArea(double = 20, double = 10.1); Call's parameter list can be blank
A function ________ contains the statements that make up the function. a. prototype b. parameter list c. expression d. definition e. call
definition
If a function does not have a prototype, default arguments may be specified in the function ________.
header
It is a good programming practice to ________ your functions by writing comments that describe what they do.
document
part of a 2D array
double array[//row][//columns];
how to code a header with a reference variable?
double deduct(double &name)
This function causes a program to terminate, regardless of which function or control mechanism is executing.
exit()
T or F Before you can perform a selection sort, the data must be stored in ascending order.
f
T or F The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order.
f
T or F Using a binary search, you are more likely to find an item than if you use a linear search.
f
what engine would process double pieces[13]?
for(i=0; i<13; i++)
This is a collection of statements that performs a specific task.
function
disadvantage of linear search
it is inefficient
A(n) ________ search uses a loop to sequentially step through an array.
linear
The ________ is adequate for searching through small arrays.
linear search
This type of variable is defined inside a funtion and is not accessible outside the function.
local
what does a static variable do?
makes a local variable keep the same variable
The name of the array stores the ____________ of the first array element.
memory address
A binary search begins with the ________ element of an array.
middle
advantage of binary search
more efficient
A function can have zero to many parameters, and it can return this many values.
only one
If a function is called more than once in a program, the values stored in the function's local variables do not __________ between function calls.
persist
A function _____________ eliminates the need to place a function definition before all calls to the function.
prototype
When used as parameters, these types of variables allow a function to access the parameter's original argument.
reference
This statement causes a function to end.
return
A two-dimensional array can be viewed as _____________ and ______________.
rows and columns
A ________ algorithm is a method of locating a specific item of information in a larger collection of data.
search
The advantage of a linear search is its:
simplicity
Array elements must be ________ before a binary search can be performed.
sorted
parameters
special variable that holds a value being passed into a function
The value of this type of local variable persists between function calls.
static
how to make a static local variable?
static int variableName;
This is a dummy function that is called instead of the actual function it represents.
stub
By using the same ____________ you can build relationships between data stored in two or more arrays.
subscript
To access an array element, use the array name and the element's:
subscript
T or F Before you can perform a binary search on an array, the data must be in ascending sorted order.
t