Add Two Matrix code

//Matrix Addition.

#include<stdio.h>
main()
{
 int a[10][10],b[10][10],c[10][10];
 int m,n,i,j,sum=0;
 printf("enter the no of rows and col in matrix\n");
 scanf("%d%d",&m,&n);
 
 
 for (i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 {
  printf("enter the data in array a[%d][%d] And b[%d][%d]\n",i,j,i,j);
  scanf("%d%d",&a[i][j],&b[i][j]);
 }
}


for (i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 {
  c[i][j]=a[i][j] + b[i][j];
 }
}
printf("sum of matrix a And b :");
 for (i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 {
  printf(" %d  ",c[i][j]);
 }
}
}

No comments:

Post a Comment