0

[SOLVED]Why this code is not giving correct output? (Multiply 2 matrices) c++

https://code.sololearn.com/cgfKtdTIL7Mg/?ref=app If I give M1(2*1) = 1 2 And M2(1*2) = 3 4 Then M3(2*2) should be = 3 4 6 8 But output is 0 0 0 0 And for other values also, it gives incorrect outputs (not always o). I can't figure out the error here. Please help. (And yes, I need to find the error here not any other method to find multiplication) (Ignore spelling or grammar mistakes, if any😁)

15th Feb 2021, 11:04 AM
Yugal Kishore
5 ответов
+ 6
Yugal Kishore at line 76 , it is M2 not M1
15th Feb 2021, 11:31 AM
Abhay
Abhay - avatar
+ 2
Abhay thanks. This silly mistake took 1 hour of frustration!
15th Feb 2021, 11:48 AM
Yugal Kishore
+ 2
Happens sometimes , happy coding :)
15th Feb 2021, 11:49 AM
Abhay
Abhay - avatar
+ 2
On the for loop with the comment "getting M2" You are using M1 when you want to use M2
15th Feb 2021, 12:00 PM
Anastacia Ru
Anastacia Ru - avatar
+ 1
Anastacia Ru yup I got it now. thanks for answering.
15th Feb 2021, 1:14 PM
Yugal Kishore