C print 2D array code example
Example 1: matrix c declaration
int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17};
Example 2: double array in c
int disp[2][4] = {
{10, 11, 12, 13},
{14, 15, 16, 17}
};
Example 3: C print 2D array
#include <stdio.h>
#define MAX 10
int main()
{
char grid[MAX][MAX];
int i,j,row,col;
printf("Please enter your grid size: ");
scanf("%d %d", &row, &col);
for (i = 0; i < row; i++) {
for (j = 0; j < col; j++) {
grid[i][j] = '.';
printf("%c ", grid[i][j]);
}
printf("\n");
}
return 0;
}