Intro computer programming final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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

Line 3

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

To assign the contents of one array to another, you must use

a loop to assign the elements of one array to the other array

What is the data type of the following function prototype's return value? int myFunction(double);

int

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

int scores[25];

Algorithms used to arrange random data in some order are ________ algorithms.

sorting

An array of string objects that will hold five names would be declared with which of the following statements?

string names[5];

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

the same data type

Using a linear search to find a value that is stored in the last element of an array that contains 20,000 elements, ________ elements must be compared.

20,000

In the following function prototype, how many parameter variables does this function have? int myFunction(double, double, double);

3

What will the following code display? #include <iostream> using namespace std; int getValue (int); int main () int x = 2: cout << getValue (x) << endl; return 0; } int getValue (int num) return num + 5:

7

A function ________ contains the statements that make up the function.

Definition

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

False

A local variable and a global variable may not have the same name within a program.

False

Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.

False

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

False

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

False

C++ limits the number of array dimensions to two.

False

If you attempt to store data past an array's boundaries, it is guaranteed to cause a compiler error.

False

When a function is called, flow of control moves to the function's prototype.

False

You are more likely to find an item by using a binary search than by using a linear search.

False

The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function? void swap (int nuni, int num2) { int temp = nam2; num2 = num1; num1 = temp; }

The swap function must use reference parameters.

A parameter is a special-purpose variable that is declared inside the parentheses of a function definition.

True

If you are using the bubble sort algorithm to sort an array in descending order, the smaller values move toward the end.

True

It is not considered good programming practice to declare all of your variables globally.

True

One reason for using functions is to break programs into manageable units or modules.

True

The amount of memory used by an array depends on the array's data type and the number of elements in the array.

True

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

True

Subscript numbering in C++

begins with zero

The following is the pseudocode for which type of algorithm? For maxElement = each subscript in the array, from the last to the first For index = 0 To maxElement - 1 If array (index] > array linder + 1] swap arraylinder] with arraylinder + 1] End If End For End For

bubble sort

A function is executed when it is:

called

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

descending order

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

double

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

exit

A ________ variable is declared outside all functions.

global

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

legal in C++

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

local

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

name

The ________ is automatically appended to a character array when it is initialized with a string constant.

null terminator

A two-dimensional array can have elements of ________ data type(s).

one

A two-dimensional array can be viewed as

rows and columns

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

scores[2]

A ________ algorithm is a method of locating a specific item of information in a larger collection of data.

search

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

selection, bubble

The advantage of a linear search is its

simplicity

Array elements must __________ before a binary search can be performed.

sorted


Ensembles d'études connexes

Mental health ( hard) first 29 questions!

View Set

Macroeconomics - 40% of assessment

View Set

P2P Chapter 4 Parliamentary reform and the Great Reform Act 1832

View Set

Labor Unions and Laissez Faire Capitalism

View Set

Bravo Ingredient/Sauce Descriptions

View Set

Chapter Eleven: Federal Tax and Health Insurance

View Set