Q: What is an array in C++?
-
A
A collection of different data types
-
B
A collection of same data type elements stored in contiguous memory
-
C
A function that stores multiple values
-
D
A pointer variable
B
Answer:
B
Explanation:
An array in C++ is used to store multiple values of the same data type in a continuous block of memory.
This allows easy access to elements using an index.
Example:
int a[3] = {10, 20, 30};
All elements are integers and are stored next to each other in memory.
Why other options are incorrect
-
A) Different data types ❌ → Arrays store only same data type
-
C) Function ❌ → Arrays are not functions
-
D) Pointer variable ❌ → An array is not a pointer (though related)
Correct Answer:
B) A collection of same data type elements stored in contiguous memory
Description:
Arrays store multiple values of the same type in consecutive memory locations for efficient access.
Related Topic:
Share Above MCQ