R

Ram Sharma • 193.88K Points
Coach

Q. What is the correct definition of an array?

  • (A) An array is a set of elements of the same type stored in non-contiguous memory locations
  • (B) An array is a set of elements of the same type stored in contiguous memory locations
  • (C) An array is a set of elements
  • (D) None of the above
  • Correct Answer - Option(B)
  • Views: 152
  • Filed under category C++

Explanation by: Mr. Dubey

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)

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics