create a c++ program with a function named average that calculates the average of the students 5 SCORES using array. Let the student enter the scores in the main function and the function average will calculate the average.
#include <iostream>
using namespace std;
int average(int* scores);
int main()
{
   int scores[5];
   cout << "Enter 1st score: ";
   cin >> scores[0];
   cout << "Enter 2nd score: ";
   cin >> scores[1];
   cout << "Enter 3rd score: ";
   cin >> scores[2];
   cout << "Enter 4th score: ";
   cin >> scores[3];
   cout << "Enter 5th score: ";
   cin >> scores[4];
   cout << "\nAverage: " << average(scores) << endl;
}
int average(int* scores) {
   return (scores[0] + scores[1] + scores[2] + scores[3] + scores[4]) / 5;
}
Comments
Leave a comment