#Help meeee

6 messages · Page 1 of 1 (latest)

brisk dew
#

Can you please help me what went wrong in my code? The results are different from the way I expected to be. It should be the printed output of sum, highest and lowest number of the elements on each rows of an array. But it shows, the printed output of the last row.

upper adderBOT
#

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.

serene urchin
#

You shouldn't have to pass your results variables as parameters to the function. You are returning them.
Just declare the results as stack variables outside all loops (i.e. start of the function) and initialise them accordingly.

#

Example:

int findSum( int row, int col, int a[row][col] )
{
  int sum = 0;
  // rest of the function
  return sum;
}
#

Do not set the sum back to zero for each row, like you are doing rn.
That will lead to the function calculating the sum of just the last row.

upper adderBOT
#

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.