//program to multiply two matrix and print its result

void main()

{

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

clrscr();

printf("\nEnter
the elements for matrix A ");

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

{

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

{

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

}}

printf("\nEnter
the elements for matrix B ");

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

{

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

{

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

}}

printf("\nThe
multiplication result of the above matrices is given below\n");

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

{

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

{

c[i][j]=0;

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

{

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

}

}

}

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

{

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

{

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

}

printf("\n");

}

getch();

}

**Output**

Enter the
elements for matrix A

1 2

3 4

Enter the
elements for matrix B

5 4

6 7

The
multiplication result of the above matrices is given below

17 18

39 40

## No comments:

## Post a Comment