The output should be like this:
Grade 1: 90
Grade 2: 86
Grade 3: 95
Grade 4: 76
Grade 5: 92
Grade 6: 83
Grade 7: 100
Grade 8: 87
Grade 9: 91
Grade 10: -1
Average Grade: 88%
/******************************************************************
#include <iostream>
using namespace std;
/******************************************************************
* This function will get the Grades!!
****************************************************************/
int getGrades()
{
const int SIZE = 10;
int Grades[SIZE];
int average[SIZE];
average = 0;
for (int i = 0; i < SIZE; i++)
// Fill the list
{
cout << "Grade " << i + 1 << ": ";
cin >> Grades[i];
average = average + Grades[i];
}
// get Average
average = average / SIZE;
cout << "Average Grade: " << average
<< "%"
<< endl;
}
/**************************************************
* main function
****************************************************/
int main()
{
// display the result
Your "average" var should not be an array, but a single value. And your addition/division would be done using integer arithmetic, discarding the decimal portion. Which is likely not what you want when computing averages. Try making average a float.