234k views
2 votes
Declare a 2d array called table with 4 columns and 3 rows of type integer.

1 Answer

2 votes

Final answer:

To declare a 2D array named 'table' with 4 columns and 3 rows in C, use the declaration 'int table[3][4];'. This array can store a total of 12 integers.

Step-by-step explanation:

To declare a 2D array called table with 4 columns and 3 rows of type integer, you would define it in most programming languages with a syntax similar to the following:

int table[3][4];

The 'int' keyword indicates that the elements of the array are integers. The first number in the brackets (3) specifies the number of rows, and the second number (4) indicates the columns. Thus, 'table' is an array that can store 12 integer values in total.

An example initialization of this array in C could be:

int table[3][4] = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11}
};

This would assign the values from 0 to 11 to the cells of the table, with each row representing a new line in the curly braces.

User Davi Lima
by
9.1k points