-
Arrays are always indexed starting at subscript _____ .
- 0
- 1
- "start"
- "begin"
-
How many integers can the array named numbers contain?
int numbers[10]
- 11 (got it wrong the first time... thought it was 11)
- 9
- 10
- 0
-
Which of the following is a legal array definiton in C++?
-
int numbers[0];
-
double 5numbers[5];
-
real numbers[5];
-
float numbers[10];
-
-
C++ treats an array name as:
- all of the array elements
- a variable
- the location in memory of first array element
- the first array element
-
All array elements must be:
- enclosed in square brackets
[]
- constants
- literals
- of the same type
- enclosed in square brackets
-
Given the following array declaration, how would you display
100.7
from the array?double temperatures[] = {98.6, 95.2, 88.7, 100.7, 89.0};
-
cout << temperatures[4] << endl;
-
cout << 100.7 << endl;
-
cout << temps[3] << endl;
-
cout << temperatures[3] << endl;
-
-
Given the following array declaration, what would the following code display?
double temperatures[] = {98.6, 95.2, 88.7, 100.7, 89.0};
cout << temperatures[5] << endl;
- [x] garbage data
- [ ] 89.0
- [ ] it won't compile
- [ ] it will generate an "out of range error"
*I got this one wrong!! I thought it was either "it won't compile" or "it will generate an 'out of range error'"...*
-
How would you define a vector named temperatures that contains doubles?
- vector temperatures;
- vector double temperatures;
- vector [double] temperatures;
- double vector temperatures
-
How would you determine the number of elements contained in a vector named temperatures?
- length(temperatures);
- tmeperatures.length();
- temperatures.size();
- temperatures.num_elements();
-
What is one way that vectors and arrays are different?
- vectors always more efficient than arrays
- arrays can only store primitive types
- vectors can vary their capacity as the program runs, but arrays are fixed in size
- vectors elements cannot be accessed using their subscript