Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can somebody please give me a second opinion with the following multiple choice: Question 1 To prevent modification of a built-in array s values when

Can somebody please give me a second opinion with the following multiple choice: Question 1 To prevent modification of a built-in array s values when you pass the built-in array to a function: A. The built-in array must be declared static in the function. B. The built-in array parameter can be preceded by the const qualifier. C. A copy of the built-in array must be made inside the function. D. The built-in array must be passed by reference.

Question 2 Which of the following gives the number of elements in the array int r[ 10 ]? A. sizeof r B. sizeof ( *r ) C. sizeof r / sizeof ( int ) D. sizeof ( *r ) / sizeof ( int )

Question 3 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.

Question 4 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.

Question 5 Which of the following is not a correct way to initialize a built-in array? A. int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; B. int n[] = { 0, 7, 0, 3, 8, 2 }; C. int n[ 5 ] = { 7 }; D. int n[ 5 ] = { 9, 1, 9 }

Question 6 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.

Question 7 A double subscripted array declared as array, 3> values; has how many elements? A. 15 B. 13 C. 10 D. 8

Question 8 You can sort an array with the Standard Library s: A. sort function. B. sort_array function. C. array_sort function. D. None of the above.

Question 9 sizeof: A. Is a binary operator. B. Returns the total number of elements in an array. C. Usually returns a double. D. Returns the total number of bytes in a variable.

Question 10 Which of the following is false about a function to which a built-in array is being passed? A. It always knows the size of the built-in array that is being passed. B. It is being passed the address of the first element in the built-in array. C. It is able to modify the values stored in the built-in array. D. The built-in array s name is used as an argument in the function call.

Question 11 Given a built-in array of ints named values, which of the following statements would sort the array? A. sort( values.begin(), values.end() ); B. sort( values.array_begin(), values.array_end() ); C. sort( begin( values ), end( values ) ); D. sort( array_begin( values ), array_end( values ) );

Question 12 A string array is commonly used for: A. Command-line arguments. B. Storing an extremely long string. C. Storing multiple copies of the same string. D. Displaying floating-point numbers to the screen.

Question 13 Which of the following is not a correct way to initialize the array named n? A. array< int, 5 > n = { 0, 7, 0, 3, 8 }; B. array< int, 5 > n = { 0, 7, 0, 3, 8, 2 }; C. array< int, 5 > n = { 7 }; D. array< int, 5 > n = { 9, 1, 9 };

Question 14 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.

Question 15 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.

Question 16 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.

Question 17 Which statement would be used to declare a 10-element integer array c? A. array c< 12 >; B. array c< int, 12 >; C. array< 12 > c; D. array< int, 12 > c;

Question 18 Linear search can be used on: A. Unsorted arrays. B. Sorted arrays. C. Integer arrays. D. Any of the above.

Question 19 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 < items.size(); ++i ) cout << items[ i ] << endl; B. for ( int item : items ) cout << items[ item ] << endl; C. for ( int item : items.size() ) cout << item << endl; D. for ( int item : items.size() )

Question 20 Which statement would be used to declare a 10-element integer array c? A. array c = int[ 10 ]; B. c = int[ 10 ]; C. int array c[ 10 ]; D. int c[ 10 ];

-Thank you

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions