CH. 7 C++
rows,columns
A two-dimensional array can be viewed as _____ and _____.
one
A two-dimensional array can have elements of ____________ data types.
several identical arrays
A two-dimensional array is like _____ put together.
All of these
A two-dimensional array of characters can contain ______________.
null terminator
The __________ is automatically appended to a character array when it is initialized with a string constant.
elements
The individual values contained in an array are known as
Memory address
The name of an array stores the ______ of the first array element.
range variable
The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the
implicit array sizing
The statement: int grades[ ] = { 100, 90, 99, 80}; shows an example of:
It creates a vector object with a starting size of 10.
What does the following statement do? vector<int> v(10);
It creates a vector object with a starting size of 10 and all elements are initialized with the value 2. Answer: D
What does the following statement do? vector<int> v(10, 2);
4
What is last legal subscript that can be used with the following array? int values[5];
3 5
What will the following C++ 11 code display? vector<int> numbers { 3, 5 }; for (int val : numbers) cout << val << endl;
0
What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl;
87 66 55
What will the following code display? int numbers[] = { 99, 87, 66, 55, 101 }; for (int i = 1; i < 4; i++) cout << numbers[i] << endl;
An error will occur when the code runs
What will the following code do? const int SIZE = 5; double x[SIZE]; for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; }
all but the first dimension
When writing functions that accept multi-dimensional arrays as arguments, _______ must be explicitly stated in the parameter list.
int array[10];
Which of the following has a valid c++ array definition?
int scores [10];
Which of the following is a valid C++ array definition?
vector<int> v;
Which statement correctly defines a vector object for holding integers?
vector<int> n { 10, 20 };
Which statement correctly uses C++ 11 to initialize a vector of ints named n with the values 10 and 20?
initialization list
An ________________ can be used to specify the starting values of an array.
for loop
An array can easily be stepped through by using a
the same data type
An array can store a group of values, but the values must be
string names[5];
An array of string objects that will hold 5 names would be declared using which statement
illegal in C++
An array with no elements is ________
constant integer expression,zero
An array's size declarator must be a _________ with a value greater than _______
the row subscript of the element, the column subscript of the element
An element of a two-dimensional array is referred to by _______ followed by _____
initialized, declared
Arrays may be __________ at the time they are ___________
subscript
By using the same _______ you can build relationships between data stored in two or more arrays
scores[2]
Given the following declaration, where is the value 77 stored in the scores array? int scores[] = {83, 62, 77, 97};
1000
How many elements does the following array have?
you must furnish an initialization list
If you leave out the size declarator in an array definition:
legal in C++
It is ____________ to pass an argument to a function that contains an individual array element, such as numbers[3].
begins with zero
Subscript numbering in C++
push_back
This vector function is used to insert an item into a vector.
pop_back
This vector function removes an item from a vector
size
This vector function returns the number of elements in a vector.
empty
This vector function returns true if the vector has no elements.
subscript
To access an array element, use the array name and the element's
a loop to assign the elementsofonearraytotheoherarray
To assign the contents of one array to another, you must use
name
To pass an array as an argument to a function, pass the __________ of the array.
FALSE
True/False: An array initialization list must be placed on one single line.
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: C++ limits the number of array dimensions to two.
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 statement: double money[25.00]; is a valid C++ array definition.
TRUE
True/False: When you pass an array as an argument to a function, the function can modify the contents of the array.
arrays
Unlike regular variables, these can hold multiple values.
55
int numbers[] = {99, 87, 66, 55, 101 }; cout << numbers[3] << endl;