(For easier understanding, I simplified this problem*:)
In short, I'm trying to write a program that has a function, getAverage(), which should calculate and return the average of the values stored in the array testscores[].
I'm uncertain as to what to set as the 'for loop' conditions; I'd appreciate any help.
Thank you in advance!
Code:#include <iostream>
using namespace std;
double getAverage(int testscores[]);
int main ()
{
int testscores[] = {100, 90, 95};
cout << getAverage(testscores);
system ("pause");
return 0;
}
double getAverage(int testscores[])
{
int sum = 0;
int i;
for (i = 0; ; i++) // what would I put in between the semicolons?
{
sum += testscores[i];
}
int average;
average = sum/i;
return average;
}