Question:

How does a 2D array differ from a 1D array in a programming language like C++?

Show Hint

1D array → Linear list
2D array → Matrix structure (rows × columns)
Updated On: Mar 15, 2026
  • A 2D array stores characters only
  • A 2D array has rows and columns
  • A 2D array stores only integers
  • A 2D array cannot store multiple values
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Concept:
Arrays are data structures used to store multiple values of the same data type in contiguous memory locations.
Step 1:Understanding a 1D array.
A one-dimensional array (1D array) stores elements in a single linear sequence. Each element is accessed using one index. Example in C++: \[ int arr[5] = \{1,2,3,4,5\}; \] Here each element is accessed using a single index such as arr[0], arr[1], etc.
Step 2:Understanding a 2D array.
A two-dimensional array (2D array) stores data in a matrix-like structure consisting of rows and columns. Example: \[ int matrix[3][3]; \] Elements are accessed using two indices such as: \[ matrix[row][column] \]
Step 3:Key difference.
The primary difference is the number of dimensions used to organize the data:
  • 1D array → single dimension
  • 2D array → two dimensions (rows and columns)
Conclusion:
Thus, a 2D array differs from a 1D array because it stores data in rows and columns.
Was this answer helpful?
0
0