COP 3014 Chapter 7

Ace your homework & exams now with Quizwiz!

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

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

Which statement correctly defines a *vector* object for holding integers?

vector<int> v;

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

vector<int>n{10,20};

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

0

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

1000

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

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

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.

Subscript numbering in C++

begins with zero

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

It creates a vector object with a starting size of 10 and initializes all the elements 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.

An array can easily be stepped through by using a

a for loop

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

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

an illegal array declaration, or an illegal array initialization

Unlike regular variables, __________ can hold multiple values

arrays

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

An array with no elements is

illegal in C++

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

initialization list

Arrays must be __________ at the time they are __________

initialized, declared

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

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

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]

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

size

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

string names[5];

A two-dimensional array of characters can contain

strings of the same length, strings of different lengths & uninitialized elements

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

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

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

the same data type

If you leave out the size declarator in an array definition

you must furnish an initialization list


Related study sets

Unit 10 Reviewing the Basics Quiz

View Set

Hands-On Ethical Hacking and Network Defense, Chapter 5

View Set

Chapter 22: Nursing Management of the Postpartum Woman at Risk (Prep U)

View Set

Path 63 Renal BV Disorders - Renal Cell Carcinoma

View Set