A program to find the multiplication of the given matrices
[sourcecode=c]/*******************************************************
* MYCPLUS Sample Code – https://www.mycplus.com *
* *
* This code is made available as a service to our *
* visitors and is provided strictly for the *
* purpose of illustration. *
* *
* Please direct all inquiries to saqib at mycplus.com *
*******************************************************/
#include
#include
void main()
{
int mat1[2][2],mat2[2][2],mat3[2][2],i,j,k;
clrscr();
printf(“************A program to find the multiplication of the given matrices***********\n\n”);
printf(“************Enter the value for the 1st matrix************\n”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“\nEnter the value for %d row,%d column:”,i+1,j+1);
scanf(“%d”,&mat1[i][j]);
}
}
printf(“\n************Enter the value for the 2nd matrix************\n”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“\nEnter the value for %d row,%d column:”,i+1,j+1);
scanf(“%d”,&mat2[i][j]);
}
}
printf(“\n****************************The given matrices are*****************************\n\n”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“%d\t”,mat1[i][j]);
}
printf(“\n”);
}
printf(“\n\n”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“%d\t”,mat2[i][j]);
}
printf(“\n”);
}
printf(“\n****************************The multiplication of the matrices is*************\n\n”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
mat3[i][j]=0;
for(k=0;k<2;k++)
{
mat3[i][j]=mat3[i][j]+(mat1[i][k]*mat2[k][j]);
}
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“%d\t”,mat3[i][j]);
}
printf(“\n”);
}
getch();
getch();
}[/sourcecode]