Hello,
I would really appreciate if someone could tell me what is wrong with this function. When I execute the program it returns the memory address and not the calculated average. I have not included the entire program, there is a sort function and scores are entered by the user in Main. I tested Main and it is fine also sort is a tad wanky but I think perhaps it could be because I am not using the pointers correctly in function avg.
Does it look to be correct in logic and syntax?
Thanks for any help.
#include<iostream>
using namespace std;
double avg(double *scores, int numScores)
{
double total = 0.0;
double average;
sortScores(scores, numScores);
for(int count = 0; count < numScores; count++)
{
total += *scores;
scores++;
}
average = total / numScores;
return average;
}