1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/****************************************************************************
 * 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 <cs50.h>
#include <stdio.h>


// number of quizzes per term
#define QUIZZES 2


int
main(int argc, char *argv[])
{
    float grades[QUIZZES];
    int i;

    // ask user for scores
    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 < 3; i++)
        printf("%.2f\n", grades[i]);
}