Thursday, April 25, 2013

Program to enter two 3x3 matrices and calculate the product of given matrices.

4:05 PM


#include<stdio.h>
#include<conio.h>

void main()
{
  int a[3][3],b[3][3],c[3][3];
  int i,j,k;
  clrscr();
  printf("Enter the matrix A\n");
     for(i=0;i<3;i++)
      {
          for(j=0;j<3;j++)
           {
            scanf("%d",&a[i][j]);
           }
     }
  printf("Enter the 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] = 0;
           for(k=0;k<3;k++)
           {
             c[i][j] += a[i][k] * b[k][j];
           }
         }
      }
  printf("\n\nThe product of two matrix\n\n" );
    for(i=0;i<3;i++)
    {
       for(j=0;j<3;j++)
       {
         printf("%d\t",c[i][j]);
       }
       printf("\n");
    }
getch();

}

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 comments:

Post a Comment

 

© 2013 TechSansar. All rights resevered. Designed by Templateism

Back To Top