I think that if you look carefully at the compiler error, it will mention that you have specified an invalid octal constant.
This is because any number that begins with a 0
(that isn't followed by an x
) is interpreted as an octal constant. Valid digits for octal constants are 0
-7
, with 8
and 9
being invalid.
The simple solution is to remove the leading zeroes.
Note that you're comparing an int
with the values of eight and nine. Even if the user input a number with a leading zero, the binary representation of the integer value does not store that fact. Looking for a leading zero might be useful if you were looking at a string rather than an integer.