COSC 1320 C++ PROGRAMMING
Homework 6
Part I
True/False
1. The amount of memory used by an array depends upon the array's data type and
the number of elements the array can hold.
a. True b. False
2. Array size declarators can be either integer constants or integer variables.
a. True b. False
3. To assign all the contents of one array to another, you can use the
assignment operator.
a. True b. False
4. When you pass an array as an argument to a function, the function can modify
the contents of the array.
a. True b. False
5. A one-dimensional array can only store elements of a single data type, but a
two-dimensional array can hold data of two different data type.
a. True b. False
6. An element of a two-dimensional array is referenced by the array name and two
subscripts, first the element row number and then the element column number.
a. True b. False
7. Any sorting algorithm, such as bubble sort or selection sort, that can be
used on data stored in an array can also be used on data stored in a vector.
a. True b. False
8. Using a binary search, you are more likely to find an item than if you use a
linear search.
a. True b. False
9. The statement
double money[25.0];
is a valid C++ array definition.
a. True b. False
10. In C++ If you attempt to store more data in an array than it can hold, the
compiler will issue an error.
a. True b. False
11. Each individual element of an array can be accessed by the array name and an
element number, called a subscript.
a. True b. False
12. An individual array element can be processed or passed to a function like a
regular C++ variable.
a. True b. False
13. The array definition
int grades[ ];
is legal because C++ allows arrays to be implicitly sized.
a. True b. False
14. When searching for an item in an unordered set of data, binary search can
find the item more quickly than linear search.
a. True b. False
Part II
Multiple Choice
15. An array of 8 integers named scores can have its contents displayed with the
Statement
a. cout << scores;
b. cout << scores[];
c. cout << scores[8];
d. cout << scores[0-7];
e. None of these
16. Unlike regular variables, arrays can hold multiple
a. data types b. named constants
c. values d. variables
e. None of these
17. The individual values contained in an array are known as
a. members b. elements
c. numbers d. subscripts
e. None of these
18. To access an array element, use the array name and the element's
a. data type b. subscript
c. name d. value
e. None of these
19. The statement int grades[ ] = { 100, 90, 99, 80 }; is an example of
a. default arguments
b. an illegal array declaration
c. an illegal array initialization
d. implicit array sizing
e. None of these
20. By using the same ________ you can build relationships between data stored in
two or more arrays.
a. array name b. data
c. subscript d. arguments
e. None of these
21. To step through an array, accessing each element one by one, an appropriate
construct to use is a
a. cout statement
b. reference variable
c. named constant
d. for loop
e. None of these
22. When an array is passed to a function, it is actually __________ the array
that is passed.
a.the starting memory address of
b.a copy of all the values in
c.the value stored in the first element of
d.the data type and size
e.None of these
23 The _________ sort usually performs fewer exchanges than the ________ sort.
a. bubble, selection
b. binary, linear
c. selection, bubble
d. bubble, linear
e. None of these
24. To determine that a value is not present in an unordered array of 50 items,
using linear serach, requires examining an average of __________ values.
a. 1 b. 25 c. 49 d. 50 e. 51
25. To locate a value in an ordered array of 50 items, using linear search,
requires examining at most _________ values.
a. 1 b. 25 c. 49 d. 50 e. 51