2-Dimensional Array
xxxxxxxxxx
c
Copy code
#include <stdio.h>
#define ROWS 3
#define COLS 4
int main() {
// Declaration and initialization of a 2-dimensional array
int matrix[ROWS][COLS] = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
};
// Printing the elements of the 2-dimensional array
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
printf("%d ", matrix[i][j]);
}
printf("\n");
}
return 0;
}