In: Computer Science
(5)When you pass an array to a function, the function
receives
Group of answer choices
a copy of the array
a reference to the array
the data type of the array and the number of elements it contains
the data type of the array and a pointer to its first element
(6)Which of the following statements is not true about a built-in
array?
Group of answer choices
Elements that aren’t initialized will be assigned default values.
Its elements must have the same data type.
The number of elements is fixed.
The number of elements must be set at compile time.
(7)Code Example 12-1
const int size = 6;
int ages[size] { 37, 26, 42, 49, 53, 34 };
(Refer to Code Example 12-1.) What statement would you use to store
a pointer to the first element in the built-in array in a variable
named ptr?
Group of answer choices
int ptr = ages;
auto ptr = ages;
int ptr = ages.begin();
auto ptr = ages.begin();
(8)Which of the following statements is not true about a
two-dimensional array?
Group of answer choices
It can be thought of as a table of rows and columns.
You can’t define and initialize it at the same time.
You use two subscript operators to refer to its elements.
You can use it with C strings if you need to access individual characters.
(9)You may not want to use range-based for loops with built-in
arrays because
Group of answer choices
built-in arrays don’t have a size() member function
you don’t typically need to operate on every element in a built-in array
range-based for loops don’t work correctly with built-in arrays that are passed to functions
it’s easier to use a counter with a for loop
ANS:
Q) When you pass an array to a function, the function receives
the data type of the array and a pointer to its first element
This is because when every an array is passed to a function, The function gets data type of array and a pointer to its first element as when ever the array will be printed without giving the index, it will print the first element of the array
Q) Which of the following statements is not true about a built-in array?
The number of elements must be set at compile time.
This is because number of elements can be set before compile time too.
Q) What statement would you use to store a pointer to the first element in the built-in array in a variable named ptr?
int ptr = ages.begin();
This is because of ages.begin is the write syntax without any error
Q) Which of the following statements is not true about a
two-dimensional array?
Group of answer choices
You can use it with C strings if you need to access individual characters.
This is not true because it doesn't relate it with two dimensional array specifically
Q) You may not want to use range-based for loops with built-in arrays because
range-based for loops don’t work correctly with built-in arrays that are passed to functions
COMMENT DOWN FOR ANY QUERIES!!!
HIT A THUMBS UP IF YOU DO LIKE IT!!!