I have created a program to read from an external file. The program must locate the first maximum and the second. I am unsure about how to find the second maximum. Possibly by resetting the first max, but I am unsure how to do it. Here is my code for the program to locate the first max. What should i do from here?
I am a big time beginner. Thanks!
/* Homework 14 */
#define FILENAME "exam2.dat"
/* Declare and initalize variables. */
int j=0, locmax, flag0=0, x, max, count=0;
double sum=0.0, ave;
/* Open file. */
/*Read file. */
while (fscanf(data, "%i", &x) == 1)
/* Compute average. */
/* Print summary. */
printf("Average: %7.2f \n", ave);
printf("Maximum: %3i \n", max);
printf("Location of Max: %3i \n", locmax);