Quote:
when i print it finds there are 2 even numbers
because your program just prints the first integer of the input sequence.
As matter of fact, if you feed it with the input sequence
3 19 27 42
it then prints
I found 3 even numbers
As it stands, your program is completely broken. You're given an input sequence that you must
entirely process (well, you must process it until you find
0
).
Try the following approach:
- define a counter of even numbers, say
even_count
and initialise it with 0
. - read an integer, say
n
from the input sequence (use scanf
). - if
n==0
the print the value of the even_counter
and exit the program - here
n
is non-zero, check for its parity: if n
is even the increment the even_count
- goto point 2