C Program to Compute Sum of Two Matrices Full Project For Beginners

  • Post author:
  • Post category:c++
  • Post comments:0 Comments

 

 

main.c

 

 

#include<stdio.h>
#include<conio.h>
void main()
{
   int m1[20][20],m2[20][20],r,c,i,j;
   clrscr();
   printf("\nEnter the order of Matrix\t:");
   scanf("%d%d",&r,&c);
   printf("\nEnter the elements of matrix 1\t:\n");
   for(i=0;i<r;i++)
      for(j=0;j<c;j++)
         scanf("%d",&m1[i][j]);
   printf("\nEnter the elements of matrix 2\t:\n");
   for(i=0;i<r;i++)
      for(j=0;j<c;j++)
         scanf("%d",&m2[i][j]);

   printf("\nThe sum is:\n\n\t");
   for(i=0;i<r;i++)
   {
      for(j=0;j<c;j++)
         printf(" %d",m1[i][j]+m2[i][j]);
      printf("\n\t");
   }
   getch();
}

Leave a Reply