Write a program that calculates the average of a group of te

Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. After the program finishes it should ask the user if they want to calculate another set of test scores. If the user indicates they want to continue the program should run again. This process should continue until the user chooses not to continue.

Solution

#include <stdio.h>
int findLowest(int scores[5]) //function to compute lowest score
{
   int lowest =999;
   int i;
   for(i=1;i<=5;i++)
   {
       if(scores[i] < lowest)
       lowest=scores[i];
   }
   printf(\"\ Lowest=%d\",lowest);
   return lowest;
}

void getScore(int *score) //reference to one element of scores array as argument
{
   printf(\"\ Enter Score\");
   scanf(\"%d\",score);
   if(*score<0)
   {
   printf(\"\ Error:Enter positive value\"); validate a score
   scanf(\"%d\",score);
   }
  
}
void calcAverage(int scores[5]) //calculate average score
{
   float average=0;
   int i;
   int lowest=findLowest(scores); // call to lowest() function
   for (i=1;i<=5;i++)
   {
       average=average+scores[i];
   }
   average=average-lowest; //exclude lowest score
   average =average/4;
   printf(\"\ Average excluding lowest= %f\",average);
  
}


int main(void)
{
   int scores[5],i;
   for(i=1;i<=5;i++)
   {
   getScore(&scores[i]); //call to getScore()
   }
   for(i=1;i<=5;i++)
   {
       printf(\"\ score %d:%d\",i,scores[i]);
   }
   calcAverage(scores); //call to calcAverage() function

   return 0;
}

Output:

Success time: 0 memory: 2172 signal:0

 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: v
 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: v

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site