COP3014 - Chapter 7 Multiple Choice

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What will the following C++11 code display? vector <int> numbers {3,5}; for (int val : numbers) cout << val << endl;

3 5

What is the last legal subscript that can be used with the following array? int values[5];

4

What will the following code display?int numbers[] = {99, 87, 66, 55, 101};cout << numbers[3] << endl;

55

An array can easily be stepped through by using a

for loop

This vector function removes an item from a vector.

pop_back

This vector function is used to insert an item into a vector.

push_back

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

scores[2]

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

string names[5];

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

the range variable

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

the row subscript of the element followed by the column subscript of the element

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

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

What will the following code display? int numbers[] = {99,87,66, 55, 101}; for (int i= 1; i< 4; i++) cout << numbers [i] << " " ;

87 66 55

Subscript numbering in C++

begins with zero

This vector function returns the number of elements in a vector.

size

To access an array element, use the array name and the element's ___________.

subscript

Arrays must be __________ at the time they are __________.

compiled, typed

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

constant integer expression, zero

The individual values contained in an array are known as

elements

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

empty

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

false

An array initialization must be all on one line.

false

This following statement shows an example of ________. int grades][ ] = {100, 90, 99, 80};

implicit array sizing

This following statement shows an example of ___________. int grades][ ] = {100, 90, 99, 80};

implicit array sizing

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 scores[3].

legal in C++

The name of an array stores the __________ of the first array element.

memory address

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

one

Which statement correctly uses C++11 to initialize a vector of ints named n with the values 10 and 20?

vector<int> n {10, 20};

Which statement correctly defines a vector object for holding integers

vector<int> v;

If you leave out the size declarator in an array definition

you must furnish an initialization list

What does the following code do? const int SIZE = 5; double x [SIZE]; for (int i= 2; i<= SIZE; i++) { x[i] = 0.0; }

An error will occur when the code runs.

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

When writing functions that accept multi-dimensional arrays as arguments, ________ must be explicitly stated in the parameter list.

all but the first dimension

Unlike regular variables, __________ can hold multiple values.

arrays

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

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

In C++11 the range-based for loop is best used in situations where you need the element subscript for some purpose.

false

The following statement is a valid C++ definition: double money[25.00];

false

An array with no elements is

illegal in C++

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

int scores[25];

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

int sizes[10];

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

name

A two-dimensional array can be viewed as

rows and columns

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

subscript

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

the same data type

A vector object automatically expands in size to accommodate the items stored in it.

true

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

true

Each individual element of an array can be accessed by the array name and the element subscript.

true

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

true

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 variable.

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

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

true


Kaugnay na mga set ng pag-aaral

Probability: Simple and Compound Events

View Set

Chapter 8 Lifting and Moving Patients

View Set

RAMEXAM22 - Ram Expert Exam Truck Foundations PT 2

View Set

Gerontology Sleep/Physical Activity/Fall Risk

View Set

Platelets disorder FA USMLERx flash crds p.397 Mar 30 16

View Set

3. Structure & Function of the Kidney - Part II

View Set