#Why isn't the code working perfectly? Also how can I optimise it?

13 messages · Page 1 of 1 (latest)

tawdry veldt
#

I don't know why but the last element of the resultant matrix is not giving correct value. Please help.
Output :

Enter row of first matrix : 1
Enter column of first matrix : 2
Enter row of second matrix : 2
Enter column of second matrix : 3

Enter 2 elements of first matrix :
1 2

Enter 6 elements of second matrix :
1 2 3
4 5 6

The resultant matrix is:
   9      12       0
ivory frigateBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

broken meadow
#

there are arguments not mentioned in the format string

tawdry veldt
lyric quarry
#

in line 24 (multiply function) it should be

for(int y=0; y<temp; y++)
  for(int z=0; z<col; z++)
lyric quarry
#

the second loop in the function (y loop) tells how many columns of the second matrix will be multiplied with the rows of the first matrix. The second matrix in your example output has three columns but the value of col in the function is 2. So that's why the third column in your example is 0. And the third loop is for the number of rows of the second matrix

lyric quarry
#

Sorry about the edits. I'm not used to explaining codes

ivory frigateBOT
#

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.

tawdry veldt
#

!solved