c program to multiplication of two 3*3 matrices


    /* c program to multiplication of two 3*3 matrices*/

#include<stdio.h>
#include<conio.h>
void main()
{
     int m1[3][3],m2[3][3],prod[3][3];
     int i,j,k;
     clrscr();
      printf("enter the first matrix : \n");
        for(i=0;i<3;i++)
          for(j=0;j<3;j++)
           scanf("%d",&m1[i][j]);
     printf("enter 2nd matrix : \n");
         for(i=0;i<3;i++)
           for(j=0;j<3;j++)
            scanf("%d",&m2[i][j]);

/* multiplication of matrix */
      for(i=0;i<3;i++)
     for(j=0;j<3;j++)

     {
       prod[i][j]=0;
       for(k=0;k<3;k++)
       prod[i][j]=prod[i][j]+m2[i][k]*m2[k][j];
    }

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




enter the first matrix
     4     4     4
     4     4     4
     4     4     4
enter 2nd matrix
     4     4     4
     4     4     4
     4     4     4
product matrix
    48    48    48
    48    48    48
    48    48    48

Comments

Popular posts from this blog

to arrange number descending using bubble sort technique

DIPLOMA THERMAL ENGINEERING LAB MECH ENGG