Headlines
Loading...
C program to find the product of 2 matrices

C program to find the product of 2 matrices

Write a c program to find the product of 2 matrices.*/

 

#include<stdio.h>

#include<conio.h>

void main()

{

            int a[3][3],b[3][3],c[3][3],i,j,k;

            clrscr();

            printf("\nEnter the first matrix:\n");

            for(i=0;i<3;i++)

            {

                        for(j=0;j<3;j++)

                        scanf("\t%d",&a[i][j]);

                        printf("\n");

            }

            printf("\nEnter the second matrix:\n");

            for(i=0;i<3;i++)

            {

                        for(j=0;j<3;j++)

                        scanf("\t%d",&b[i][j]);

                        printf("\n");

            }

            printf("\nProduct of two matrices\n");

            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]=c[i][j]+a[i][k]*b[k][j];

                                    }

                                    printf("%d\t",c[i][j]);

                        }

                        printf("\n");

            }

            getch();

}

 

/*Output

Enter the first matrix:

12 34 45

 

54 65 67

 

076 78 89

 

 

Enter the second matrix:

87 75 53

 

90 10 20

 

30 40 50

 

 

Product of two matrices

5454    3040    3566

12558   7380    7512

16302   10040   10038

*/


*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***