Write a c program to read and display the elements of 2d array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],i,r,c,j;
clrscr();
printf("Enter the order of matrix: ");
scanf("%d%d",&r,&c);
printf("Enter the elements\n");
for(i=0;i<r;i++)
for(j=0;j<c;j++)
scanf("%d",&a[i][j]);
printf("Matrix is\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
printf("%d",a[i][j]);
printf("\n");
}
getch();
}
Output:
Enter the order of matrix: 3
3
Enter the elements
1
2
3
4
5
6
7
8
9
Matrix is
123
456
No comments: