1. What is the index of the first element in a C++ array?
(A) 0
(B) 1
(C) 1
(D) Depends on array type
2. Which of the following correctly declares an array of 10 integers in C++?
(A) int arr(10);
(B) int[10] arr;
(C) int arr = new int[10];
(D) int arr[10];
3. What happens if you try to access an array element out of its bounds in C++?
(A) Compiler error occurs.
(B) Program automatically resizes the array.
(C) Undefined behavior occurs.
(D) The element is set to zero.
4. How many elements are there in the array int nums[5] = {10, 20, 30};?
(A) 3
(B) 5
(C) 2
(D) 4
5. Which of the following statements about C++ arrays is true?
(A) The size of an array can be changed at runtime.
(B) Arrays automatically check for out-of-bounds access.
(C) Arrays are stored in contiguous memory locations.
(D) Arrays can store elements of different data types.
6. What will be the output of the following code?int arr[] = {1, 2, 3, 4};cout << arr[2];
(A) 1
(B) 2
(C) 4
(D) 3
7. Which of the following correctly finds the number of elements in a statically declared array arr?
(A) sizeof(arr) / sizeof(int)
(B) sizeof(int) / sizeof(arr)
(C) length(arr)
(D) arr.size()
8. What is the correct way to initialize all elements of an array to zero?
(A) int arr[5] = {0};
(B) int arr[5] = (0);
(C) int arr[5] = [0];
(D) int arr[5] = { };
9. What is the output of the following code snippet?
int arr[3] = {10, 20, 30};
cout << *(arr + 1);
(A) 10
(B) 20
(C) 30
(D) Compilation error
More Array MCQs
Programming C Plus Plus MCQs Homepage
- Low-level and high-level languages MCQs
- Procedural and non Procedural languages MCQs
- C++ STANDARD LIBRARY MCQs
- Array MCQs
- Arrays MCQs 2
- Pointers Solved MCQs
- Inline Function MCQs – C++
- Top 50 Programming C++ MCQs
- MCQs of introduction to programming
- Past Papers 2022 C++ MCQs
- Past Papers 2021 C++ MCQs
- Past Papers 2020 C++ MCQs
- Past Papers 2019 C++ MCQs
- Highly Recommended C++ Important MCQs with Explanation
- OOP
- OOP intro & examples MCQs
- Classes and Inheritance MCQs
- Friend Function MCQs
- Virtual Function MCQs
- Polymorphism MCQs
- Polymorphism MCQs 2