Write in c Write a program that calculates the average of a
Write in c++
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 find Lowest() 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 <iostream>
using namespace std;
void getScore(int *score)
{
int temp;
cout << \"Enter a valid score in range (0-100)\";
cin >> temp;
while(true)
{
if(temp<0 || temp>100)
{
cout <<\"Please enter the score again.\";
cin >> temp;
}
else
break;
}
*score = temp;
}
int getLowest(int arr[])
{
int low = arr[0];
int i=0;
for(i=0;i<5;i++)
if(arr[i]<low)
low = arr[i];
return low;
}
void getAverage(int arr[])
{
int low = getLowest(arr);
int sum = 0;
int i=0;
for(i=0;i<5;i++)
{
if(arr[i]==low)
continue;
else
sum = sum+arr[i];
}
cout << \"Average is : \" << sum*1.0/4;
}
int main() {
// your code goes here
int i;
int arr[5];
char c;
while(true)
{
for(i=0;i<5;i++)
getScore(&arr[i]);
getAverage(arr);
cout << \"Do you want to continue?(y/n)\";
cin >> c;
if(c!=\'y\')
break;
}
return 0;
}

