# Thread: Need help one more time...

1. ## 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

2. You need a count of the number of numbers that are greater than or equal to the average. This is similiar to how you computed the sum of the numbers, except that now you would be incrementing a count.

3. So my if statement is incorrect?

4. The body of your if statement's block is incorrect. You also need to initialise total to 0.

5. Code:
```    for (x = 0; x < 10; x++)
{
if (ary[numbers] >= ave)
{
total = equal + 1;
}
}```
you never updated numbers, the loop will finish with either [strike]total = 0 or total = 10[/strike]
replace numbers with x and I think it will do what you want it to

edit:

you never update equal so it will keep reassigning total to be the same number

total++; should do it

Code:
```    for (x = 0; x < 10; x++)
{
if (ary[x] >= ave)
{
total++;
}
}```

6. Thanks! works great. Thank you guys for all your help again. You saved my grade! Is there a way to rep you on this forum?