What is the total number of elements in a 2D array declared as int a[3][4]; ?
2023
What is the total number of elements in a 2D array declared as int a[3][4]; ?
- A.
7
- B.
8
- C.
10
- D.
12
Attempted by 332 students.
Show answer & explanation
Correct answer: D
The declaration int a[3][4]; defines a 2D array with 3 rows and 4 columns. To find the total number of elements, multiply the sizes of both dimensions: 3 x 4 = 12. Therefore, the total number of elements is 12, making option D the correct answer.