Create a program to find the product of a 2×2 matrix

Create a program to find the product of a 2×2 matrix

 Programming c 

2×2 matrix

#include<studio.n>

#include<conio.n>

main ( )

{

      int a[2] [2], b[2][2], s[2][2]; 

int I, j, k;

clrscr(); 

Printf("Enter first matrix:\n'');

for(I=1;I<=2;I++)

{

        for (j=I;<=2;j++)

       {

            Scanf ("%d'',&a[i] [j]);

        }

}

Printf(''Enter second matrix:\n"):

for(I=1;<=2;j++)

  for (j=1;j<=2;j++) 

  {

      Scanf ("%d'',&b[i] [j]); 

  } 

for (I=1;j<2;j++)

     s[i][j]=0;

     for (k=1;k<2;k++)

     {

         s[i][j]=s[i][j]+a[i][k]*b[k][j];

      }

   }

Printf ("Matrix Multiplication is;\n''); 

for (I=1;I<=2; j++)

{

    for (j=1;j<=2;j++)

    {

        printf ("%d\t'', s[i][j]) 

     }

     Printf ("\n'');

}

getch();

}

Output– 

Enter first matrix:

10

15

9

16

Enter second matrix:

3

2

7

9

Matrix Multiplication is: 

135          155

139          162


Post a Comment

0 Comments