212k views
4 votes
How are array elements accessed in a 2D array?

a) Using 1 index
b) Using 2 indices
c) Using 3 indices
d) Using a for loop

User Plucury
by
7.4k points

1 Answer

2 votes

Final answer:

In a 2D array, elements are accessed using two indices, where the first index represents the row and the second represents the column.

Step-by-step explanation:

Array elements in a 2D array are accessed using two indices. The first index typically refers to the row number, and the second index refers to the column number.

For example, in a 2D array named myArray, the element at the first row and the first column would be accessed using myArray[0][0]. It is important to note that the indexing starts at 0, so to access the element at the third row and fourth column, you would use myArray[2][3].

User Ammar Hasan
by
7.6k points