ADDMAT
ADDMAT
#include<stdio.h>
void main()
{
int A[10][10],B[10][10],C[10][10],m,n,i,j;
clrscr();
printf("enter the rows and columns of A and B matrix\n");
scanf("%d%d",&m,&n);
printf("Enter the elements of A Matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&A[i][j]);
}
}
printf("Printing the elementa of A-Matrix\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",A[i][j]);
}
printf("\n");
}
printf("Enter the elements of B-Matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&B[i][j]);
}
}
printf("Printing the elementa of B-Matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",B[i][j]);
}
printf("\n");
}
//Addition of A and B matrices
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
C[i][j]=A[i][j]+B[i][j];
}
}
printf("The resultant addition matrix is \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",C[i][j]);
}
printf("\n");
}
getch();
}