W14: CP08 Quiz (BECC0302)
Quiz by Bryan N. Manalaotao
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
15 questions
Show answers
- Q1What is an array in C++?A fixed-size sequential collection of elements of the same typeA collection of functionsA data structure that stores values in a non-sequential mannerA single variable that can store multiple values of different types30s
- Q2How are elements in an array accessed?By their position within parenthesesBy their index within square bracketsUsing a special keywordBy using the dot operator30s
- Q3Which 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
- Q4How 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, 5int array {1, 2, 3, 4, 5};30s
- Q5What happens if you omit the size of the array during initialization?The array size is determined by the number of initial valuesThe array will not be createdThe array size defaults to 10An error occurs during compilation30s
- Q6Which statement correctly accesses the fifth element of the array balance in the course packet example?balance[5];balance[4];balance(4);balance(5);30s
- Q7What 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.0Assigns 50.0 to the sixth elementAssigns 50.0 to the fifth element, which is already 50.0Initializes the fifth element to 50.030s
- Q8What function is used to format output in the given example?printf()format()setw()setprecision()30s
- Q9Which of the following is true about multidimensional arrays in C++?The simplest form of a multidimensional array is a two-dimensional arrayThe simplest form of a multidimensional array is a three-dimensional arrayC++ does not support multidimensional arraysMultidimensional arrays must have the same number of elements in each dimension30s
- Q10How can you generate a pointer to the first element of an array?By specifying the array name with the first indexBy specifying the array name without any indexBy using the * operatorBy using the & operator30s
- Q11How can you pass an array to a function?By using the * operatorBy passing the array's name without an indexBy using the & operatorBy passing each element of the array individually30s
- Q12Can a C++ function return an array?Yes, but only single-dimensional arraysYes, but the array size must be specifiedYes, C++ allows a function to return an arrayNo, C++ functions cannot return arrays30s
- Q13What is the purpose of the setw function in the provided code example?To set the precision of floating-point numbersTo set the alignment of the output textTo set the width of the output fieldTo set the width of the input field30s
- Q14Which 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