14819 - Average grade   

Description

Implement a function average_grade that returns a student's average grade.
If the student has not taken any courses, the average grade should be 0.0.

 

grade.h

struct student {
    int grade[20];
    int count;
};

average-grade-main.c

#include <stdio.h>
#include "grade.h"

float average_grade(struct student *std_ptr);

int main(void)
{
    int i;
    struct student std;
    scanf("%d", &(std.count));
    for(i = 0; i < std.count; i++)
        scanf("%d", &(std.grade[i]));
    printf("%f\n", average_grade(&std));
    return0;
}

Input

Number of subjects.
Score.

Ex.3
99 93 100

Output

The average score.

Ex.97.333333

Sample Input  Download

Sample Output  Download




Discuss