1. Which of the following statements is true about multidimensional arrays in C++?
(A) They can only be 2D arrays
(B) The size of each dimension must be known at compile time
(C) They can store elements of different types
(D) They are always dynamically allocated
2. How do you declare a 2D array of 3 rows and 4 columns in C++?
(A) int arr[3][4];
(B) int arr(3,4);
(C) int arr[4][3];
(D) int arr{3,4};
3. What is the output of the following code? int arr[3] = {5}; cout << arr[1];
(A) 0
(B) 5
(C) Garbage value
(D) Compilation error
4. Which of the following correctly accesses the last element of an array int arr[10]; ?
(A) arr[0]
(B) arr[10]
(C) arr[last]
(D) arr[9]
5. Which operator is used to get the address of the first element of an array?
(A) *
(B) &
(C) >
(D) %
6. What happens if you partially initialize an array int arr[5] = {1, 2}; ?
(A) Compiler error occurs
(B) Remaining elements are set to zero
(C) Remaining elements are garbage values
(D) Array size reduces to 2
7. Which of the following is a valid way to pass an array to a function in C++?
(A) void func(int arr[])
(B) void func(int arr[5])
(C) void func(int *arr)
(D) All of the above
8. What is the output of the code? int arr[] = {1,2,3}; cout << sizeof(arr);
(A) Size of array in bytes
(B) 3
(C) 0
(D) Compilation error
9. Can an array in C++ be initialized with a for loop during declaration?
(A) Yes
(B) Only for global arrays
(C) No
(D) Only for character arrays
10. Which of the following is true about array names in C++?
(A) Array name is a pointer to the first element
(B) Array name can be assigned to another pointer
(C) Array name can be incremented
(D) Array name stores the array size
11. How do you declare a constant array whose elements cannot be modified?
(A) const int arr[5];
(B) int const arr[5];
(C) Both (A) and (B)
(D) int arr[5] const;
12. Identify the error in the following code snippet:
int arr[5];
arr[5] = 10;
int a b
(A) Array index out of bounds
(B) Syntax error in declaration
(C) Cannot assign value to array element
(D) No error, code works fine
Basic Concepts
Non-Linear Data Structures MCQs
Sorting and Searching Algorithms MCQs
- Data Structures MCQs 1
- Data Structures MCQs 2
- Data Structures MCQs 3
- Data Structures MCQs 4
- Data Structures MCQs 5
- Stacks Solved MCQs
- Queues MCQs
- pointer mcqs
- Array MCQs
Programming C Plus Plus MCQs Homepage
Low-level and high-level languages MCQs
Procedural and non Procedural languages MCQs
MCQs of introduction to programming
Highly Recommended C++ Important MCQs with Explanation
OOP