/* File: mode.c Find the mode of a sequence of numbers. Run with input redirection. */ #include #define MAX_SIZE 1000 int main() { int i, n, r ; double average, num ; int A[MAX_SIZE] ; // will hold the scores n = 0 ; i = 0 ; // read in the scores into array A[] while (1) { r = scanf("%d", &A[i] ) ; // end of input? if ( r <= 0 ) { break ; } i = i + 1 ; // exceeded array size? if (i >= MAX_SIZE) { break ; } } // Make n the number of items stored in A[] n = i ; // // compute the average int sum = 0 ; for (i = 0 ; i < n ; i++) { sum = sum + A[i] ; } num = n ; // num is double average = sum / num ; printf ("The average score is: %f\n", average) ; // ***** // ***** NOW YOU DO THE REST // ***** // // Declare a new count[] array. // // Initialize each element of count[] to 0. (Use a for loop.) // // Iterate through the elements of the A[] array and update count[] in // each iteration. // // Iterate through the score[] array and print out the number of times // that each score appeared. // // Iterate through the elements of the count[] array to find the maximum // count and the score with the maximum count. // // Print out the score that has the highest count and the number of // times that score appeared. return 0 ; }