I'm writing a code for the problem below and I have an issue with the function header, prototypes, and call in the main.
I'm not sure how to pass an array to the function!
//
void average (double [], int);
}
average(scores,numScores );
}
void average (double scores, int numScores) //<<===============================================================
{
int total =0;
for (int count =0 ; count< numScores; count ++)
{
total += scores [numScores];
}
int avg = total/ numScores;
cout << " The average of the scores is : " << avg << endl;
}
Ok thanks, that's fix now. But I don't get the right total, I think I'm doing something wrong in the for loop in the function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void average(double scores[], int numScores)
{
double total = 0;
for (int count = 0; count< numScores; count++)
{
total += (*scores);
}
cout << "total is" << total << endl;
double avg = total / numScores;
cout << " The average of the scores is : " << avg << endl;
}