Need help one more time...
The point of this program is to calculate the average of the array and then tell how many numbers are greater than or equal to the array. I am having trouble now with the calculating the amount greater than or equal to the array. Here's what I have so far:
Code:
#include <stdio.h>
double average (int ary[ ]);
int main (void)
{
double ave;
int ary[10];
int numbers;
int total;
int equal = 0;
int x;
printf("Enter 10 numbers: \n");
for (numbers = 0; numbers < 10; numbers++)
scanf("%d", &ary[numbers]);
ave = average(ary);
printf("Average : %f\n", ave);
for (x = 0; x < 10; x++)
{
if (ary[numbers] >= ave)
{
total = equal + 1;
}
}
printf("Total number that is greater than or equal to the average: %d\n", total);
system ("pause");
return 0;
}
double average (int ary[ ])
{
int sum = 0;
int i;
for (i = 0; i < 10; i++)
sum += ary[i];
return (sum / 10.0);
}
I keep getting 2 for the answer. Sorry if I'm getting annoying with all these help questions. Thanks again