Write a program to find the multiplication of 2X2 matrices

//this is a program to find the multiplication of two matrices
#include<stdio.h>
#include<conio.h>
void main()
{
int a[2][2],b[2][2],c[2][2],i,j,k;

printf("\n\nEnter the values of Matrix A: ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\n\nEnter any number: ");
scanf("%d",&a[i][j]);
}
}

printf("\n\nEnter the values of Matrix B: ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\n\nEnter any number: ");
scanf("%d",&b[i][j]);
}
}

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];
}
}

printf("\n\nThe Multiplication of A X B = ");
for(i=0;i<2;i++)
{
printf("\n\n");
for(j=0;j<2;j++)
{
printf("  %d  ",c[i][j]);
}
}
getch();
}


Previous
Next Post »