Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Addition of matrix

#include<stdio.h>
int main()
{
  int n,m,i,j,a[100][100],b[100][100];
  printf("Enter row and col:");
  scanf("%d%d",&n,&m);
  printf("Matrix A :
");
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
        {
          printf("a[%d][%d] : ",i,j);
          scanf("%d",&a[i][j]);
        }
    }

   printf("Matrix B :
");
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
        {
          printf("b[%d][%d] : ",i,j);
          scanf("%d",&b[i][j]);
        }
    }
  printf("Sum of matrix :
");
  for(i=0;i<n;i++)
    {
      for(j=0;j<m;j++)
        {
          printf("%d	",(a[i][j]+b[i][j]));
        }
      printf("
");
    }
}
 
PREVIOUS NEXT
Tagged: #Addition #matrix
ADD COMMENT
Topic
Name
2+2 =