#include<stdio.h>
void main()
{
int c[2][2],i,j,k,sum=0;
int a[2][2] = { {5,4},
{4,4} };
int b[2][2] = { {6,7},
{4,8} };
printf("The matrix A is :\n\n\t\t");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n\t\t");
}
printf("\nThe matrix B is :\n\n\t\t");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n\t\t");
}
printf("\nMultiplication of A and B matrix is: \n\n\t\t");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
for(k=0;k<2;k++)
{
sum+=(a[i][k]*b[k][j]);
}
c[i][j]=sum;
printf("%d\t",c[i][j]);
}
printf("\n\t\t");
}
}
void main()
{
int c[2][2],i,j,k,sum=0;
int a[2][2] = { {5,4},
{4,4} };
int b[2][2] = { {6,7},
{4,8} };
printf("The matrix A is :\n\n\t\t");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n\t\t");
}
printf("\nThe matrix B is :\n\n\t\t");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",b[i][j]);
}
printf("\n\t\t");
}
printf("\nMultiplication of A and B matrix is: \n\n\t\t");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
for(k=0;k<2;k++)
{
sum+=(a[i][k]*b[k][j]);
}
c[i][j]=sum;
printf("%d\t",c[i][j]);
}
printf("\n\t\t");
}
}
No comments:
Post a Comment