Ask Question
25 December, 04:17

write a program that calculates the average of a group of 5 testscores, where the lowest score in the group is dropped. it shoulduse the following functionsa. void getscore () should ask the use for the test score, store itin a reference parameter variable and validate it. this functionshould be called by main once for each ofthe five score to be entered.

+2
Answers (1)
  1. 25 December, 07:45
    0
    C+ + program for calculating the average of scores

    #include

    using namespace std;

    const int n=5; //As per question only 5 test scores were there

    int numbers[5];

    void getscore (int i) / /defining function for taking input

    {

    cin >> numbers[i];

    while (numbers[i]100) / /score should be between 0 to 100

    {

    cout<<"/nThe number should be between 0 to 100/n";

    cin>>numbers[i];

    }

    }

    int main () / /driver function

    {

    cout << "Enter 5 scores:/n";

    for (int i = 0; i < n; i++)

    {

    getscore (i); //calling function each time for input

    }

    int s = 101;

    double avg = 0;

    for (int i = 0; i < n; i++) / /loop for finding the smallest

    {

    s = numbers[i] < s? numbers[i] : s;

    }

    for (int i = 0; i < n; i++) / /loop for finding the Average

    {

    avg + = numbers[i];

    }

    avg - = s;

    avg / = 4;

    cout << "Average of the four scores are: " << avg<< endl; //printing the output

    return 0;

    }

    Output

    Enter 5 scores:

    4

    5

    6

    7

    8

    Average of the four scores are: 6.5
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “write a program that calculates the average of a group of 5 testscores, where the lowest score in the group is dropped. it shoulduse the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers