This is so far what I got for the output. The Exp is the right output for the test. So when I run my program through textBed it gives me the result 87 which I wanted %88. I'm very close but I still need an advice. Thank you so much!
int main()
{
getGrades();
getAverage();
return 0;
}
int getGrades()
{
int grades[10];
for (int i = 1; i <= 10; i++)
{
cout << "Grade " << i << ": "; //prompts user for grades
cin >> grades[i]; // adds values to array
}
}
int getAverage()
{
int grades[10];
int average;
int sum = 0;
int count = 0;
This: for (int i = 1; i <= 10; i++)
is not populating your 10-element array correctly. (element index starts at 0, not 1)
But the main issue is that both of your functions contain completely separate arrays, so when you call getAverage() it will not use the information you've gathered from the user in getGrades()
In fact, going by the code you've posted, I'm not sure how you've gotten that ouput?
Also: return -1;
why return -1 for a function that's supposed to calculate an average?