Engineering Problem Solving with C++, 3e Chapter 7 Test Bank
Use the following array when answering questions 1 through 4
1. When searching the list above using the binary search for key value 69, list the values which
would be examined, in the order they are examined.
2. How many values would be examined to determine that 69 is not an element of the list using
the Sequential Search for an ordered list?
3. How many values would be examined to determine that 69 is not an element of the list using
the Sequential Search for an unordered list?
4. Given the declaration string aString{“Hello”}; Show the output generated by
the following range-based for statement:
for(char ch: aString)
cout << ch << endl;
5. Given the declaration double x[] = {0.5, 1.0, 1.5, 2.0}; show the output
generated by the following range-based for statement:
for(double t: x)
cout << t << endl;
6. Given the declaration double x[] = {0.5, 1.0, 1.5, 2.0}; show the output
generated by the following range-based for statement:
for(double& t: x){
++t;
cout << t << endl;
}
7. Write a declaration statement that will declare an array of characters named vowels and
initialized to the letters a, e, i, o, u.
8. Using the following function prototype which statement about the argument passed to
parameter A is true.
void F(const int A[ ], int Cnt);
A. The argument is modified when changes are made to parameter A in function F.
B. The argument passed to parameter A must always have the same number of elements,
every time function F is invoked.
C. Changes can not be made to parameter A in function F.
D. Every element of the argument passed to parameter A must be initialized prior to
invoking function F.
.
9. A restriction on arrays in C++ is: