Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section 7.2 array s 1. An array is not : a. A consecutive group of memory locations. b. Subscripted by integers. c. Made up of

Section 7.2 arrays

1. An array is not:

a. A consecutive group of memory locations.

b. Subscripted by integers.

c. Made up of different data types.

d. None of the above.

2. Which of the following is false?

a. The last element of an array has position number one less than the array size.

b. The position number contained within square brackets is called a subscript.

c. A subscript cannot be an expression.

d. All of the above.

Section 7.3 Declaring arrays

3. Which statement would be used to declare a 10-element integer array c?

a. array c<12>;

b. array c;

c. array<12> c;

d. array c;

Section 7.4 Examples Using arrays

4. Which of the following is not a correct way to initialize the array named n?

a. array n{0, 7, 0, 3, 8};

b. array n{0, 7, 0, 3, 8, 2};

c. array n{7};

d. array n{9, 1, 9};

5. Constant variables:

a. Can be assigned values in executable statements.

b. Do not have to be initialized when they are declared.

c. Can be used to specify array sizes, thereby making programs more scalable.

d. Can be used to specify array sizes, but this makes programs harder to understand.

6. Referencing elements outside the array bounds with the [] operator:

a. Can result in changes to the value of an unrelated variable.

b. Is impossible because C++ checks to make sure it does not happen.

c. Is a syntax error.

d. Enlarges the size of the array.

Section 7.5 Range-Based for Statement

7. Assume that the array named items contains the integer values 0, 2, 4, 6 and 8. Which of the following set of statements uses the range-based for loop to display each value in items?

a. for (int i = 0; i

b. for (int item : items) { cout <

c. for (int item : items) { cout <

d. for (int item : items.size()){ cout <

8. Which of the following tasks cannot be performed using a range-based for loop?

a. Calculating the product of all the values in an array.

b. Displaying all even element values in an array.

c. Incrementing the value stored in each element of the array.

d. Accessing the elements subscript.

Section 7.6 Case Study: Class GradeBook Using an array to Store Grades

9. In order to calculate the __________ of an array of values, the array values must first be summed.

a. Average.

b. Minimum.

c. Maximum.

d. Distribution.

Section 7.7 Sorting and Searching arrays

10. Linear search can be used on:

a. Unsorted arrays.

b. Sorted arrays.

c. Integer arrays.

d. Any of the above.

11. You can sort an array with the Standard Librarys:

a. sort function.

b. sort_array function.

c. array_sort function.

d. None of the above.

Section 7.8 Multidimensional arrays

12. A double subscripted array declared as array 5>, 3> values; has how many elements?

a. 15

b. 13

c. 10

d. 8

13. Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?

a. array, 2> b; b[0][0] = b[0][1] = b[1][0] = b[1][1] = 0;

b. array, 2> b = {0};

c. array, 2> b; for (auto const &row : b) { for (auto &element : row) { element = 0; } }

d. All of the above initialize all four of the array elements to 0.

Section 7.9 Case Study: Class GradeBook Using a Two-Dimensional array

14. In a typical nested for loop (not a range-based for loop) used to process a two-dimensional array, following the end of each execution of the inner for loop:

a. The outer for loop initializes its counter variable.

b. The outer for loop increments its counter variable.

c. The inner for loop initializes its counter variable.

d. The inner for loop increments its counter variable.

Section 7.10 Introduction to C++ Standard Library Class Template vector

15. Which of the following is not true of class template vector?

a. The size of a vector can be changed after it is declared.

b. A vector can be assigned to another vector by using the assignment operator.

c. A vector object can be initialized with a copy of another vector by invoking the copy constructor.

d. A vector can store only data of type int.

16. Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking.

a. Does not, does not.

b. Does not, does.

c. Does, does not.

d. Does, does.

17. When using exception handling, place any code that might throw an exception in a __________.

a. catch block

b. try statement.

c. throw block.

d. what statement.

18. Which statement about exception handling is false?

a. Call the exception object's what member function to get the error message that's stored in the exception object.

b. Bounds checking is performed at execution time with vector member function at, and if a subscript is within the bounds of the array, the member function throws an out_of_bounds exception.

c. The catch block contains the code that handles an exception if one occurs.

d. None of the above statements in false.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

Describe the three basic types of cash flow activities.

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago