I need to create a program that reads a file, counts the number of scores, avera
ID: 3630448 • Letter: I
Question
I need to create a program that reads a file, counts the number of scores, averages the scores, and finds the highest score in the set. However, I have trouble creating a program to find the highest score. everything else works in my program however.Here is my program below:#include <stdio.h>
int
main (void)
{
int number, sum, count;
double average;
FILE *in;
in = fopen ("/ece/www/ism2008/hw3/scores.dat", "r");
sum = 0;
count = 0;
while (fscanf (in, "%d", &number) != EOF)
{
sum = sum + number;
count = count + 1;
}
fclose (in);
printf ("Number of scores read: %d ",
count);
average = (double)sum / count;
printf ("The average of the scores is %5.2lf. ",
average);
return (0);
}
Explanation / Answer
Dear Friend here is the program fixed to find the max PLEASE RATE #include int main (void) { int number, sum, count; double average; int max=0; FILE *in; in = fopen ("/ece/www/ism2008/hw3/scores.dat", "r"); sum = 0; count = 0; while (fscanf (in, "%d", &number) != EOF) { sum = sum + number; if(maxRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.