2-D array sum of rows/ columns

Jun 12, 2013 at 6:53am
For some reason my program will not add up the columns. It will print out the row sums but rounded down to the lowest integer. I can not figure out why it is doing this.
Last edited on Jun 12, 2013 at 7:52am
Jun 12, 2013 at 7:26am
1
2
arrayOfSales[5][NUMBERCOLUMNS] = total; // Illegal. You are trying to access an out of bounds index. 
                                   //Column Index numbers are 0 to NUMBERCOLUMNS-1. 

Similarly for the other function.

Also, the statement arrayOfSales[][] = total; should be out of the inner loop.


Last edited on Jun 12, 2013 at 7:27am
Jun 12, 2013 at 7:42am
Thanks!
Last edited on Jun 16, 2013 at 11:51pm
Jun 12, 2013 at 7:51am
You have declared total as an int.
Jun 12, 2013 at 7:52am
*face palm*
Topic archived. No new replies allowed.