0
Why does it always show even number if I type any letter
3 Réponses
+ 5
When you enter a string scanf fails to parse an integer. The value of "number" remains as before (0 in this case for some reason). 0 is an even number.
Try to run this code with a single character as input to see how the char remains in buffer after the first scanf:
https://code.sololearn.com/cSyNY6r7GRVu/?ref=app
+ 3
If number is divided by 2 then it is even number otherwise not
+ 2
Recheck again.
It will show different for even, odd numbers.
edit: Oh. Any letter?
Nishit Mehta your program don't read any char. it only can read an integer.