/**************************************************************************** * buggy6.c * * Computer Science 50 * David J. Malan * * Asks student for their grades but prints too many! * Can you find the bug? * * Demonstrates accidental use of a "magic number." ***************************************************************************/ #include #include /* number of quizzes per term */ #define QUIZZES 3 int main(int argc, char * argv[]) { float grades[QUIZZES]; int i; /* ask user for grades */ printf("\nWhat were your quiz scores?\n\n"); for (i = 0; i < QUIZZES; i++) { printf("Quiz #%d of %d: ", i+1, QUIZZES); grades[i] = GetFloat(); } /* print scores */ for (i = 0; i < 10; i++) printf("%.2f\n", grades[i]); }