1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2013
Posts
3
Rep Power
0

#### Odd numbers counting

what's the coding for getting the average of only the odd numbers? I really I'm confuse and I'm still new in this programming.

Pls help
2. Show us what you've written so far.
3. No Profile Picture
Offensive Member
Devshed Novice (500 - 999 posts)

Join Date
Oct 2002
Location
in the perfect world
Posts
622
Rep Power
31
Originally Posted by Kayle07
what's the coding for getting the average of only the odd numbers? I really I'm confuse and I'm still new in this programming.

Pls help

Code:
```//find the average of the odd numbers less than 100

int Ave = 0, Total = 0, Count = 0;
int Max = 100;

for(int i=0; i<=Max ; i++)
{
if( i % 2 == 0)
{
Total += i;
Count++;
}
}
Ave = Total / Count;
//print results```
PS I left a few bugs for you to find.
4. First find sum of all odd numbers and then divide it with total of of odd number.
to check odd number you can use % operator.
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2013
Posts
3
Rep Power
0
Thanks so much. it help me a lot. :)