+ 1
Make c code for matrix multiplication
I want to make a c program for multiplying a 2x3 and 3x2 matrix. I make a code but it is not working. it is giving garbage values. pls tell me ur suggestions
6 Respostas
+ 2
Can you share your code please ?
+ 2
@Sahtantu
Share the code from the C++ playground.
+ 1
int main()
{
int m1[2][3];
int m2[3][2];
int m3[2][2];
int i,j,k,s=0;
then code to take input. for loop and scanf.
for(I=0;I<2;I++)
{
for(k=0;k<2;k++)
{
s=0;
for(j=0;j<3;j++)
{
s+=m1[I][j]*m2[j][I];
}
m3[I][k]=s;
}
}
then printing m3
+ 1
isn't it supposed to be m1[i][j] * m2[j][k] ?
0
@swim no that's not problem. it's due to autocorrect.