Sep 10, 2004 #1 chevere Technical User Sep 10, 2004 10 US Does someone know how to get the sum for each column in a double subscripted array? I know how to get the sum for each row.
Does someone know how to get the sum for each column in a double subscripted array? I know how to get the sum for each row.
Sep 10, 2004 #2 Zyrenthian Programmer Mar 30, 2001 1,440 US int values[ROWS][COLS]; if this is what you mean, it is just the reverse of the row sum int rowSum = 0; for(int col = 0;col<COLS;col++) { rowSum += values[rowToSum][col]; } for columns it would be for(int row = 0;row<ROWS;row++) { colSum += values[row][colToSum]; } Matt Upvote 0 Downvote
int values[ROWS][COLS]; if this is what you mean, it is just the reverse of the row sum int rowSum = 0; for(int col = 0;col<COLS;col++) { rowSum += values[rowToSum][col]; } for columns it would be for(int row = 0;row<ROWS;row++) { colSum += values[row][colToSum]; } Matt
Sep 10, 2004 Thread starter #3 chevere Technical User Sep 10, 2004 10 US Hey thanks... I will try this evening... I understand your concept... chevere Upvote 0 Downvote