C++ MCQ Questions - Array
This section focuses on the "Array" in C++ programming langauge. These Multiple Choice Questions (MCQ) should be practiced to improve the C++ programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. _________________ which stores a fixed-size sequential collection of elements of the same type.
A. loop
B. array
C. exception
D. number
View Answer
Ans : C
Explanation: C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type.
2. An array is used to store a collection of data.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, An array is used to store a collection of data.
3. All arrays consist of __________ memory locations.
A. simple
B. contiguous
C. distant
D. None of the above
View Answer
Ans : B
Explanation: All arrays consist of contiguous memory locations.
4. The lowest address of array is?
A. 0
B. 1
C. 2
D. 3
View Answer
Ans : A
Explanation: The lowest address of array is 0.
5. The arraySize must be an integer constant greater than ?
A. 0
B. 1
C. 2
D. 3
View Answer
Ans : A
Explanation: The arraySize must be an integer constant greater than zero and type can be any valid C++ data type.
6. The number of values between braces { } can not be larger than the number of elements that we declare for the array between square brackets [ ].
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, The number of values between braces { } can not be larger than the number of elements that we declare for the array between square brackets [ ].
7. Which of the following correctly declares an array in C++?
A. array{10};
B. array array[10];
C. int array;
D. int array[10];
View Answer
Ans : D
Explanation: Because array variable and values need to be declared after the datatype only.
8. What is the index number of the last element of an array with 9 elements?
A. 0
B. 1
C. 8
D. 9
View Answer
Ans : B
Explanation: Because the first element always starts at 0. So it is on 8 position.
9. Which of the following gives the memory address of the first element in array?
A. array[0];
B. Array[1];
C. Array[2];
D. Array[3];
View Answer
Ans : D
Explanation: To get the address of ith index of an array, we use following syntax (arr + i). So as we need address of first index we will use (arr + 0) equivalent to arr.
10. C++ supports multidimensional arrays.
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, C++ supports multidimensional arrays.
Discussion