program of addition of 2 matrix in c language.

■》 Program for addition of two matrix in c.           language. 

#include<stdio.h>
#include<conio.h>
void main()
{
  int a[2][2],b[2][2],c[2][2],i,j;
  clrscr();
  printf("enter the 4 numbers for first matrix=");
  for(i=0; i<2; i++)
  {
   for(j=0; j<2; j++)
   {
    scanf("%d",&a[i][j]);
   }
  }
  printf("enter the 4 numbers for second matrix=");
  for(i=0; i<2; i++)
  {
   for(j=0; j<2; j++)
   {
    scanf("%d",&b[i][j]);
   }
  }
  for(i=0; i<2; i++)
  {
   for(j=0; j<2; j++)
   { 
   c[i][j]=a[i][j]+b[i][j];
   }
  }
   printf("the addition of matrix is=\n");
   for(i=0; i<2; i++)
  {
   for(j=0; j<2; j++)
   { 
   printf("%d\t",c[i][j]);
   }
   printf("\n");
  }
  getch();
  }
■》Output->





Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.