C++ Ch 7 - Arrays

Ace your homework & exams now with Quizwiz!

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 };

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

True

A two-dimensional array can be viewed as

rows and columns

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

size

The amount of memory used by an array depends on the array's data type and the number of elements in the array. Question 10 options: T/F

True

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

subscript

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

1000

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

3 5

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

An array initialization must be all on one line. T/F

False

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

False

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

False

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

False

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

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. T/F

True

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

Subscript numbering in C++

begins with zero

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

An array can easily be stepped through by using a

for loop

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

implicit array sizing

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

push_back

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

the range variable

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

name

If you leave out the size declarator in an array definition

you must furnish an initialization list

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

0 -- referencing last number, but only 2 were entered so last two are stored as 0

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

int scores[25];

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

scores[2] (because index 0 is first)

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


Related study sets

Cell Cycle and Cell Reproduction

View Set

Chapter 4 - Health Record Content & Documentation

View Set

Chapter 13: Fungal Skin Infections

View Set

chapter 12 review environmental science

View Set