I have a program that takes the average of entered numbers, and then averages only the numbers from the entered numbers over the average of all the numbers, and outputs that. For example:

Code:

What size array? 5
5 6 7 8 9
8.50 is the mean above the mean.

But my program doesn't work. Instead, I get:

Code:

What size array? 5
5 6 7 8 9
35.00 is the mean above the mean.

Can someone please help?

My code is:

Code:

#include <iostream>
#include <iomanip>
using namespace std;
float Mean(const float array[100], int n) {
float average;
for(int i = 0; i < n; ++i) {
average += array[i];
}
average /= n;
return average;
}
int main( ) {
float n;
float average;
float o;
float value = 0;
float array[100];
float newaverage = 0;
cout << "What size array? ";
cin >> o;
n = o;
for(int i = 0; i < n; ++i) {
// newarray = array[i];
cin >> array[i];
newaverage = average;
if(newaverage < average) {
newaverage = average;
}
average += array[i];
}
newaverage /= n;
cout << fixed << setprecision(2) << average << " is the mean above the mean.";
}