Chapter 8 Flashcards
Arrays and Vectors
Unlike regular variables, arrays can hold multiple …
Values
True/False: The amount of memory used by an array depends solely on the number of elements the array can hold.
False
To access an array element, use the array name and the element’s …
Subscript
True/False: If a C++ program contains the following array definition
int score [10] ;
the following statement would store 100 in the first array element:
score[1] = 100;
False
The statement
int grades[ ] = {100, 90, 99, 80};
Implicit array sizing
Which of the following statements correctly initialize the value variable?
A) int value = 8;
B) int value{8};
C) int value(8);
D) All of the above
E) Both A and B, but not C
(D)
Which of the following statements will correctly carry out the operation stated in the comment to its right.
A) array 2 = array1 // Copy the elements sofo array 1 into array 2.
B) cout «_space;array 2 // Output the elements stored in array 2.
C) array 2 = 5; // Place a 5 in each element of array2.
D) None of the above
E) A and B, but not C
(D)
By using the same [Blank] you can build relationships between data stored in two or more arrays.
Subscript
To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use [Blank] loop.
A for loop
True/False: Arrays can be passed to functions, but individually array elements cannot be.
False
When an array is passed to a function, it is actually [Blank] the array that is passed.
the starting memory address of
True/False: When you pass an array as an argument to a function, the function can modify the contents of the array.
True
A two-dimensional array can be viewed as …
A table with rows and columns
The elements of an array can be
A) strings
B) Structures
C) Objects
D) Any of the above
E) None of the Above
(D)
True/False: An element of a two-dimensional array is referenced by the array name and two subscripts, first the element tow number and then the element column number.
True