CS/CE 218 Quiz #10 15 November, 1991 Name: TA: 1. (10 points) Find all the bugs (if any) in the following code. Write "none" if there are no bugs. The program is supposed to print the average of the integers it reads from standard input. (Note that scanf returns the number of items it reads from standard input; so testing it's return value against 1 tests for illegal input or end of file, which you can assume is correct.) #include #define MAX_STUDENTS 75 int main() { int n; /* number of scores */ int total; /* total of all scores */ int scores[MAX_STUDENTS]; /* scores for each student */ while ((scanf("%d", &scores[n]) == 1)) { total += scores[n]; ++n; } printf("n = %d\n", n); printf("Average = %g\n", (double) total / (double) n); return 0; } 2. (12 points) Parenthesize the following expressions and compute their values. (That is, complete the following table.) Values should be computed assuming that the following declarations (with initializations) are in effect (for each line): int i = 4, j = 6; int * r; int * p = &i; int * q = &j; expression fully parenthesized equivalent value -------------------------------------------------------------- p == & i p == (& i) 1 * * & p 6 * * p / * q * (r = &j) *= * p