Re: Odd Even Zero Counter?
Well, what the code is doing at present is reading in a number, and telling you if the number is zero, odd, or even. It does nothing about the individual digits of the number.
You need a way to read in the number, num, and then (in a loop, likely) peel off the digits (in base 10, I'm guessing) and use your code on each digit. Here's some pseudocode for what I think you need to do.
CountDigits(number : integer)
1. zero := 0
2. odd := 0
3. even := 0
4. number := |number|
5. while number > 0
6. do digit := number % 10
7. if digit = 0 then zero := zero + 1
8. else if digit % 2 = 1 then odd := odd + 1
9. else even := even + 1
a. number := floor(number / 10) ! integer division, so round down... floor
b. return (zero, odd, even)
This code takes as input an integer and returns an ordered triple (zero, odd, even) with the counts of the zero, odd, and even digits. Notice that this code works for positive and negative numbers and for the number zero does not count any digits at all (this can be changed by including it as a special case, if you want zero=1 when number=0).