Ask 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 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. 14 December, 12:41
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers