I'm trying to establish for each student from a data file an average, their lowest and maximum grades. The problem comes when I add in the portion with a back slash next to it. Not only does it not input the values but it completely messes up the array. Any ideas? Am I just mis-placing my code?
Here is the input file.Code:#define GRADES 5 #define STUDENTS 10 #define <stdio.h> int main() { /* grade[0][0] is student 0 quiz 0 */ /* grade[0][1] is student 0 quiz 1 */ int qi = 0, si = 0, grade[STUDENTS][GRADES], mins = 9999, maxs = 0, avgs = 0 , sums = 0, minq = 9999, maxq = 0, sumq = 0, avgq = 0 ; while (si < STUDENTS) { qi = 0 ; while (qi < GRADES) { if (scanf("%d",&grade[si][qi]) == EOF) // avgs = sums / GRADES; // printf("Student #%d stats: high %d, low %d, avg %d. \n", si, maxs, mins, avgs); break; // else if (grade[si][qi] < mins) // mins = grade[si][qi]; // else if(grade[si][qi] > maxs) // maxs = grade[si][qi]; // sums += grade[si][qi]; qi++; } si++; } for (si = 0; si < STUDENTS ; si++){ printf("Student #%2d: ",si); for (qi = 0; qi < GRADES; qi++) printf("%6d ",grade[si][qi]); printf("\n"); } return 0; }
64
251
680
221
892
122
242
109
566
743
364
455
148
167
138
413
456
149
0
245
422
268
184
110
433
221
222
0
347
182
205
485
116
200
206
184
332
286
122
206
194
286
335
341
146
228
248
992
620
283
2
8
Edit: Put in the backslash modifiers.



LinkBack URL
About LinkBacks


