Wednesday, February 11, 2015

C program to read a matrix of size mxn and display it on the screen


C program to read a matrix of size mxn and display it on the screen

#include<stdio.h>
#include<conio.h>

void main()
{
int a[5][5],n,m,i,j;
clrscr();
printf("Enter value of m and n: ");
scanf("%d%d",&m,&n);
printf("
Enter elemets of the matrix:
");


for(i=0;i<m;++i)
for(j=0;j<n;++j)
scanf("%d",&a[i][j]);
printf("
The Matrix is:
");


for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
printf("%d ",a[i][j]);
printf("
");

}
getch();
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.