0

Why does it always show even number if I type any letter

https://code.sololearn.com/cAK7cZiHgMS4/?ref=app

6th Jun 2023, 8:47 AM
Nishit Mehta
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
6th Jun 2023, 10:46 AM
Kevin ★
+ 3
If number is divided by 2 then it is even number otherwise not
6th Jun 2023, 10:28 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 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.
6th Jun 2023, 9:11 AM
Jayakrishna 🇮🇳