Q. What is the correct definition of an array?
β
Correct Answer: (B)
An array is a set of elements of the same type stored in contiguous memory locations
Explanation:
An array in programming (especially in C/C++, Java, etc.) is defined as:
A collection of elements of the same data type, stored in contiguous memory locations, and accessed using an index.
Example in C:
int arr[3] = {10, 20, 30};
- All elements are of type int
- They are stored in memory one after another (contiguous)
- Can be accessed using index: arr[0], arr[1], arr[2]
β Option A is incorrect:
Non-contiguous memory would imply a linked list, not an array.
β Correct Answer: (B)