# W14: CP08 Quiz (BECC0302)

## Quiz by Bryan N. Manalaotao

### Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

15 questions
• Q1
What is an array in C++?
A fixed-size sequential collection of elements of the same type
A collection of functions
A data structure that stores values in a non-sequential manner
A single variable that can store multiple values of different types
30s
• Q2
How are elements in an array accessed?
By their position within parentheses
By their index within square brackets
Using a special keyword
By using the dot operator
30s
• Q3
Which of the following correctly declares a 10-element array of doubles named balance?
double[10] balance;
array<double, 10> balance;
double balance = new double[10];
double balance[10];
30s
• Q4
How can you initialize an array during its declaration?
int array[5] = 1, 2, 3, 4, 5;
int array[5] = {1, 2, 3, 4, 5};
int array[5] 1, 2, 3, 4, 5
int array {1, 2, 3, 4, 5};
30s
• Q5
What happens if you omit the size of the array during initialization?
The array size is determined by the number of initial values
The array will not be created
The array size defaults to 10
An error occurs during compilation
30s
• Q6
Which statement correctly accesses the fifth element of the array balance in the course packet example?
balance[5];
balance[4];
balance(4);
balance(5);
30s
• Q7
What does the following code do? double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0}; balance[4] = 50.0;
Reinitializes the fourth element to 50.0
Assigns 50.0 to the sixth element
Assigns 50.0 to the fifth element, which is already 50.0
Initializes the fifth element to 50.0
30s
• Q8
What function is used to format output in the given example?
printf()
format()
setw()
setprecision()
30s
• Q9
Which of the following is true about multidimensional arrays in C++?
The simplest form of a multidimensional array is a two-dimensional array
The simplest form of a multidimensional array is a three-dimensional array
C++ does not support multidimensional arrays
Multidimensional arrays must have the same number of elements in each dimension
30s
• Q10
How can you generate a pointer to the first element of an array?
By specifying the array name with the first index
By specifying the array name without any index
By using the * operator
By using the & operator
30s
• Q11
How can you pass an array to a function?
By using the * operator
By passing the array's name without an index
By using the & operator
By passing each element of the array individually
30s
• Q12
Can a C++ function return an array?
Yes, but only single-dimensional arrays
Yes, but the array size must be specified
Yes, C++ allows a function to return an array
No, C++ functions cannot return arrays
30s
• Q13
What is the purpose of the setw function in the provided code example?
To set the precision of floating-point numbers
To set the alignment of the output text
To set the width of the output field
To set the width of the input field
30s
• Q14
Which function is used to format the output of array elements in the given example?
format()
printf()
setw()
setprecision()
30s
• Q15

What is the index of the first element in a C++ array?

-1

1

It depends on the array type

( 0 )

30s

Teachers give this quiz to your class