#include<stdio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],i,j,row,col;
clrscr();
printf("How many rows : ");
scanf("%d",&row);
printf("How many columns : ");
scanf("%d",&col);
printf("Enter your 1st matrix :\n");
for(i=0;i<row;++i)
for(j=0;j<col;j++)
{
printf("Element(%d,%d) :",i+1,j+1);
scanf("%d",&a[i][j]);
}
clrscr();
printf("\nEnter your 2nd matrix :\n");
for(i=0;i<row;++i)
for(j=0;j<col;++j)
{
printf("Element(%d,%d) :",i+1,j+1);
scanf("%d",&b[i][j]);
}
clrscr();
for(i=0;i<row;++i)
for(j=0;j<col;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
printf("\nThe 1st matrix is :\n\t");
for(i=0;i<row;++i)
{
for(j=0;j<col;j++)
printf("%d\t",a[i][j]);
printf("\n\t");
}
printf("\nThe 2nd matrix is :\n\t");
for(i=0;i<row;++i)
{
for(j=0;j<col;j++)
printf("%d\t",b[i][j]);
printf("\n\t");
}
printf("\nThe sum of matrices is :\n\t");
for(i=0;i<row;++i)
{
for(j=0;j<col;j++)
printf("%d\t",c[i][j]);
printf("\n\t");
}
getch();
}
0 comments:
Post a Comment