Help getting chart to add correctly
I am having trouble getting the chart to print correctly. I attached the whole source so anyone can run and see the problem. The total for each size is wrong except for the extra large.
I am new at this and I could be missing something obvious. Please help. Thanks. I noted what I think is the problem below, along with the full attachment. :)
Code:
/* /* mp4id230.c - sweatshop inventory program
/* find_college_total() - this function finds the total number shirts per type.
*/
void find_college_total(int shirts[][SHIRTS], int colleges[]) {
int total = 0, i, j;
for (i = 0; i < SHIRTS; i++) {
total = 0;
for (j = 0; j < COLLEGES; j++) {
total += shirts[i][j];
}
colleges[i] = total;
}
}
------------------------------------------------------------------------
/* output_mainbody() - This function is just a loop that goes through the 2D
* array so the chart has some numbers in it. It from time to time calls
* the output_left() function so it has names on the left side
*/
void output_mainbody(int shirts[COLLEGES][SHIRTS], int totalcollege[]) {
int j, i;
for(j = 0; j < SHIRTS; j++) {
NL;
output_left(j);
for(i = 0; i < COLLEGES; i++) {
printf("%d ",shirts[i][j]);
}
printf("%d\n",totalcollege[j]);
}
}
/* output_chart() - the chart that gets printed out. pretty much this just runs the
* other functions like main()
*/
void output_chart(int shirts[COLLEGES][SHIRTS], int colleges[], int inv[]) {
int total = 0, type = 0;
output_header(COLLEGES);
output_mainbody(shirts, colleges);
output_bottom(inv, colleges);
}
return 0;
} */