Addition of matrix

                    
                   Addition of matrix

 Addition of matrix means that two matrix are added and addition of both matrix is putted in into third matrix.



C program to add matrix:-
 
#include <stdio.h>
#include <conio.h>

void main()
{
 int a[3][3],b[3][3],c[3][3],i,j;
 clrscr();
 printf("\n\t Enter First Matrix : ");
for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
   scanf("%d",&a[i][j]);
  }
 }
 printf("\n\t Enter Second Matrix : ");
for(i=0;i<3;i++)
 {
for(j=0;j<3;j++)
  {
   scanf("%d",&b[i][j]);
  }
 }
for(i=0;i<3;i++)
 {
 for(j=0;j<3;j++)
  {
   c[i][j]=a[i][j]+b[i][j];
  }
 }
 printf("\n\t Matrix Addition is : \n\n");
for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
   printf("\t %d",c[i][j]);
  }
  printf("\n");
 }
 getch();
}


Output :- 

Enter First Matrix : 2 1 2 3 2 1 2 3 3 Enter Second Matrix : 2 1 0 2 3 0 1 1 2 Matrix Addition is : 4 2 2 5 5 1 3 4 5

Comments

Popular posts from this blog