Code
Statistics
Two changes: fix the nan and count more.
At least one grade
Right after reading count, the same kind of while as for a grade:
while (count < 1) {
printf("At least one grade is needed.\n");
count = read_int("How many grades? ");
}
Now division by 0 can no longer happen.
Smallest, largest, failed
Three new variables before the loop, and three ifs at the end of it:
if (grade < lowest) {
lowest = grade;
}
if (grade > highest) {
highest = grade;
}
if (grade < 5) {
failed++;
}
What they start from matters. lowest starts at 10, the largest possible grade, so the first grade always replaces it. highest starts at 1 for the same reason. If lowest started at 0, no grade would be smaller, and the answer would always be 0. failed counts the failed grades.
Run it
The same input: 3, 9, 11, 4, 10. At the end you get:
Average: 7.67
Lowest: 4, highest: 10
Failed: 1
Try 0 for "How many grades?" too: the program asks again.
Commit: Add grade statistics.