Delicious Digg Facebook Favorites More Stumbleupon Twitter

Thursday 20 September 2012

sum of two matrices



                                      /* sum of two matrices */

            #include<stdio.h>
            main()
            {
                   int j,k,a[3][3],b[3][3],c[3][3];
                   clrscr();
                   printf("\nEnter the elements of matrix :");
                   for(j=0;j<3;j++)
                  {
                          for(k=0;k<3;k++)
                          {
                              printf("\nenter elements for a[%d][%d]:",j,k);
                              scanf("%d",&a[j][k]);
                           }
                  }
                   for(j=0;j<3;j++)
                  {
                          for(k=0;k<3;k++)
                         {
                             printf("\nenter elements for b[%d][%d]:",j,k);
                             scanf("%d",&b[j][k]);
                         }
                  }
                  printf("\nthe matrix is ..:\n");
                  for(j=0;j<3;j++)
                  {
                          for(k=0;k<3;k++)
                         {
                          c[j][k]=a[j][k]+b[j][k];
                          printf("\t%d",d[j][k]);
                             
                         }
                          printf("\n");
                  }
                  getch();
 
      }

0 comments:

Post a Comment