C program to do the multiplication of two matices

Code:
#include<stdio.h>
void main()
{
int mat1[3][3],mat2[3][3],rmat[3][3];
int i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter a %dcoloum %drow of matrix1");
scanf("%d",&mat1[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter a %dcoloum %drow of matrix2");
scanf("%d",&mat2[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
rmat[i][j]=0;
for(k=0;k<3;k++)
{
rmat[i][j]=rmat[i][j]+mat1[i][k]*mat2[k][j];
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",rmat[i][j]);
}
printf("\n");
}
}

Comments

Popular posts from this blog

C++ programming toll plaza simulation program