MY mENU


Tuesday 20 March 2012

Add Two Matrices And Store the Values

Add Two Matrices And Store the Values:

#include
#include
void main()
{
  int a[3][3],b[3][3],c[3][3],i,j;
   clrscr();
     printf("Enter the elements into matrix A\n");
      for(i=0;i<3;i++)
        for(j=0;j<3;j++)
          scanf("%d",&a[i][j]);
   

    printf("\nEnter the elements into matrix B\n");
      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];

      for(i=0;i<3;i++)
       {
         printf("\t\t");
           for(j=0;j<3;j++)
             printf("%d\t",c[i][j]);
               printf("\n\a");
               }
      getch();
   }

No comments:

Post a Comment