I have read a file to an array successfully. However, when I attempt to pass the array to the function calcAvg(calculate average) and return the average, I get a zero.
//Function prototype
double calcAvg(double [], int);
//Function call
calcAvg(score,SIZE);
I set a variable called score_length (in main) to get the size of the array. I had to declare an array to hold 500 elements, and, read a data file with an unknown number of elements.
double calcAvg(double score[], int SIZE)
{
int index; //Counter set to index array.
double total = 0; //Accumulator.
double avg = 0; //Variable to hold average score.
//Index through array to get test scores
for(index = 0; index < score_length; index++);
//Variable to hold total of scores.
total += score[index];
avg = (total / score_length);
return avg;
}