Skip to content
doubtly

2 answers

Answer: data_type array_name[rows][columns];

A two-dimensional array stores data in the form of a table (matrix). The first size gives the number of rows and the second the number of columns; the total number of elements is rows × columns.

int m[3][4];                       /* 3 rows, 4 columns = 12 integers */
int a[2][3] = { {1, 2, 3},
                {4, 5, 6} };       /* with initialisation */

An element is accessed as array_name[i][j], where i is the row index and j the column index, both starting from 0. In the example above, a[1][2] is 6. When initialising, the number of rows may be left out, but the number of columns must be given: int a[][3] = {...};.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.