You are using a version without Ads of this website. Please, consider donating:

I'm trying to get this program to output how many grades are above or equal to the average and how many are below the average.

 ``1234567891011121314151617181920212223242526272829`` `````` #include using namespace std; int main() { float grade[10]; // 10 array slots int count; float total = 0; double average; for (count = 1; count <= 10; count++) { cout << "Enter grade " << count << ": "; { cin >> grade[count]; } } //printing the grades entered to be display on screen again. cout << "You have entered the following grades: " << endl; for(count = 1; count <= 10; count++) total = total + grade[count]; average = total/10; cout << "Your average of ten grades are: " << average << endl; //Output of average system ("pause"); return 0; } ``````
Last edited on
 ``12`` ``````float grade[10]; // 10 array slots // numbered 0 to 9 ``````

`for (count = 1; count <= 10; count++) //10 is out of bounds `

You need to get used to dealing with arrays that start at zero, this is the idiom for doing something 10 times:

 ``123`` ``````for (count = 0; count < 10; count++) { //do it 10 times }``````

Hope this helps
Last edited on
Thank you for your feedback, however, I'm trying to find out how to get the program to output how many grades are above or equal to the average and how many are below the average.
So you have an array with grades in it, and you have an average value- can you figure out how to do it?
Topic archived. No new replies allowed.