Addition two Matrices
#include<stdio.h>
#define MAX 10
void main()
{
int a[MAX][MAX],b[MAX][MAX],c[MAX][MAX],i,j,n;
printf("Enter the size of matrix: \n");
scanf("%d",&n);
printf("\nEnter the 1st matrix: \n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the 2nd matrix: \n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
}
return 0;
}
#include<stdio.h>
#define MAX 10
void main()
{
int a[MAX][MAX],b[MAX][MAX],c[MAX][MAX],i,j,n;
printf("Enter the size of matrix: \n");
scanf("%d",&n);
printf("\nEnter the 1st matrix: \n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the 2nd matrix: \n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is\n");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("%d\t",c[i][j]);
}
return 0;
}