> both the if and else statements get executed for every case.
Look the output closely (input is prefixed with '> ')
enter the no to be printed
> a
Not a number
enter the no to be printed
Not a number
enter the no to be printed
> 4
A number
enter the no to be printed
Not a number
enter the no to be printed
note that it executes the else case, but in another iteration of the loop (it display the "enter the no..." message).
You are processing the line break