COSC 1436 Exam 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

True/False: Before you can perform a bubble sort, the data must be stored in descending order.

False

True/False: Before you can perform a selection sort, the data must be stored in ascending order.

False

True/False: If you attempt to store data past an array's boundaries, it is guaranteed that the compiler will issue an error.

False

True/False: The bubble sort is an easy way to arrange data into ascending order, but it cannot arrange data into descending order.

False

True/False: Using a binary search, you are more likely to find an item than if you use a linear search.

False

True/False: You must furnish an argument with a function call.

False

Arrays may be ________ at the time they are ________.

Initialized at the time they are declared

How many elements does the following array have? int bugs[1000];

1000

Which line in the following program contains the header for the showDub function? 1 #include <iostream> 2 using namespace std; 3 4 void showDub(int); 5 6 int main() 7 { 8 int x = 2; 9 10 showDub(x); 11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 }

15, void showDub(int num)

What is the output of the following program? void doSomething(int); int main() { int x=2; cout << x<< endl; doSomething(x); cout << x << endl; return 0; } void doSomething (int& num) { num=0; cout << num << endl; }

2 0 0

What is the output of the following program? void doSomething(int); int main() { int x=2; cout <<x<< endl; doSomething(x); cout << x<< endl; return 0; } void doSomething(int num) { num=0; cout <<num<< endl; }

2 0 2

Look at the following function prototype. int myFunction(double, double, double) How many parameter variables does this function have?

3

What is the output of the following program? void showDub(int) int main() { int x=2; showDub(x) cout << x << endl; return 0; } void showDub(int num) { cout << (num*2)<< endl; }

4 2

What is the output of the following program? int getValue (int); int main () { int x=2; cout << getValue(x) << endl; return 0; } int getValue(int num) { return num+5; }

7

In a function header, you must furnish: A)data type(s) of the parameters B)data type of the return value C)the name of function D)names of parameter variables E)All of these

All of these

An array's size declarator must be a ________ with a value greater than ________.

Constant integer expression with a value greater than 0

True/False: A function's return data type must be the same as the function's parameter(s).

False

True/False: A linear search can only be implemented with integer values.

False

True/False: A local variable and a global variable may not have the same name within the same program.

False

True/False: Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement. array1 = array2;

False

True/False: A vector object automatically expands in size to accommodate the items stored in it.

True

True/False: An individual array element can be processed like any other type of C++ variable.

True

True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript.

True

True/False: Global variables are initialized to zero by default.

True

True/False: One reason for using functions is to break programs into manageable units, or modules.

True

A two-dimensional array of characters can contain ________.

all of these

Subscript numbering in C++________.

begins with zero

A(n) ________ search is more efficient than a ________ search.

binary, linear

Here is the header for a function named computeValue: Which of the following is a valid call to the function?

computeValue(10);

A ________ argument is passed to a parameter when the actual argument is left out of the function call.

default

Look at the following function prototype. int myFunction(double); What is the data type of the funtion's parameter variable?

double

This vector function returns true if the vector has no elements.

empty

A(n) ________ can be used to specify the starting values of an array.

initialization list

It is ________ to pass an argument to a function that contains an individual array element, such as numbers[3].

legal in C++

This type of variable is defined inside a function and is not accessible outside the function.

local

A binary search begins with the ________ element of an array.

middle

A function can have zero to many parameters, and it can return this many values:

only one

The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the ________.

range variable

This statement causes a function to end.

return

A two-dimensional array can be viewed as ________ and ________.

rows, columns

The value in a ________ variable persists between function calls.

static local

By using the same ________ you can build relationships between data stored in two or more arrays.

subscript

An element of a two-dimensional array is referred to by ________ followed by ________.

the row subscript of the element, the column subscript of the element

Which statement correctly defines a vector object for holding integers?

vector<int>v;

What does the following statement do? vector<int> v(10, 2);

It creates a vector object with a starting size of 10 and all elements are initialized with the value 2.

What does the following statement do? vector<int> v(10);

It creates a vector object with a starting size of 10.

True/False: If an array is partially initialized, the uninitialized elements will be set to zero.

True

True/False: In C++ 11, you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference.

True

True/False: In the average case, an item is just as likely to be found near the beginning of an array as near the end.

True

True/False: It is not considered good programming practice to declare all of your variables globally.

True

True/False: The amount of memory used by an array depends upon the array's data type and the number of elements in the array.

True

True/False: The number of comparisons made by a binary search is expressed in powers of two.

True

True/False: When you pass an array as an argument to a function, the function can modify the contents of the array.

True

True/False: You may use the exit() function to terminate a program, regardless of which control mechanism is executing.

True

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function.

call

These types of arguments are passed to parameters automatically if no argument is provided in the function call.

default

When an array is sorted from highest to lowest, it is said to be in ________ order.

descending

It is a good programming practice to ________ your functions by writing comments that describe what they do.

document

This function causes a program to terminate, regardless of which function or control mechanism is executing.

exit()

An array can easily be stepped through by using a ________.

for loop

Data that is sorted in ascending order is ordered ________.

from lowest to highest value

This is a collection of statements that performs a specific task

function

A ________ variable is declared outside all functions.

global

If a function does not have a prototype, default arguments may be specified in the function ________.

header

An array with no elements is ________.

illegal in C++

The statement: int grades[ ] = { 100, 90, 99, 80}; shows an example of:

implicit array sizing

Which of the following is a valid C++ array definition?

int array[10];

A(n) ________ search uses a loop to sequentially step through an array.

linear

To pass an array as an argument to a function, pass the ________ of the array.

name

Regardless of the algorithm being used, a search through an array is always performed ________. from lowest to highest element from highest to lowest element beginning with the middle element using a binary search none of these

none of these

When used as parameters, these types of variables allow a function to access the parameter's original argument.

reference

Given the following declaration, where is the value 77 stored in the scores array? int scores[] = {83, 62, 77, 97};

scores[2]

The ________ sort usually performs fewer exchanges than the ________ sort.

selection, bubble

The value in this type of local variable persists between function calls.

static

An array of string objects that will hold 5 names would be declared using which statement? A) string names[5]; B) string names(5); C) string names5; D) String[5] names; E) None of these will work.

string names[5];

An array can store a group of values, but the values must be:

the same data type


Conjuntos de estudio relacionados

Chapter 21 - The Statement of Cash Flows Revisited

View Set

Scientists and what they discovered- atoms

View Set

Osgood Schlatter Syndrome/Sinding Larson Johansson Syndrome

View Set

MGM Q1 - Managerial Roles and Functions

View Set

Chapter 15 Writing and Completing Reports and Proposals

View Set