print 2d array in c
// most of the time I forget that there should be matrix[i][j], not matrix[i]
#include
// Abdullah Miraz
int main(){
int i, j;
int matrix[2][3] = {{2,3,4,5}, {7,8,9,1}};
for(i=0;i< 2 ; i++){
for(j=0;j<3;j++){
printf("%d ", matrix[i][j]);
}
}
}
how to get input in 2d array in c
#include
int main(){
printf("Enter the number of columns");
int i;
scanf("%d", &i);
printf("Enter the number of rows");
int y;
scanf("%d", &y);
int r[i][y];
int a;
int b;
for (a=0; a
C print 2D array
#include
#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;
}
|