+ 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

26th Sep 2017, 3:16 PM
Shantanu Shinde
Shantanu Shinde - avatar
6 Antworten
+ 2
Can you share your code please ?
26th Sep 2017, 3:35 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
@Sahtantu Share the code from the C++ playground.
26th Sep 2017, 3:55 PM
Manual
Manual - avatar
+ 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
26th Sep 2017, 3:51 PM
Shantanu Shinde
Shantanu Shinde - avatar
+ 1
isn't it supposed to be m1[i][j] * m2[j][k] ?
26th Sep 2017, 5:26 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
@swim no that's not problem. it's due to autocorrect.
27th Sep 2017, 4:14 PM
Shantanu Shinde
Shantanu Shinde - avatar