// Arup Guha
// 1/12/2013
// Solution to Programming Knights Practice Program Chapter 9 Problem 1
// Test Average: Read in test scores from a file and determine their average.

#include <stdio.h>

int main() {

    // Open the file.
    FILE* ifp = fopen("test.txt", "r");

    // Initialize variables and get the number of scores.
    int i, n, sum = 0;
    fscanf(ifp, "%d", &n);

    // Read in each score, adding it into sum.
    for (i=0; i<n; i++) {
        int score;
        fscanf(ifp, "%d", &score);
        sum = sum + score;
    }

    // Print the average.
    printf("The average test score is %.2lf.\n", (double)sum/n);

    // Close the file.
    fclose(ifp);
    return 0;
}
