I\'m using Dev-Pas 1.9.2 and am trying to make sure the program doesn\'t crash when a symbol or a letter value is entered.
I\'ve googled and googled and can\'t find
Do you really want to accept exactly four different possible inputs? (The numbers 1, 2, 3, 4, and 9) That's what you're asking for at the moment.
Note: even with a change like the first answerer suggested, your code has a major problem. What happens if a 5 or Q is given ... you complain, AND THEN EXIT THE ROUTINE.
In the original code, if I enter a 100, you'll print the "That was not allowed"... and then return 100 to the caller.
Hint: loop.
Hint 2: ensure you don't loop forever
BTW, NEVER do: ord (some character) - 48
instead, always use: ord (some character) - ord ('0')
Why? Two obvious reasons:
readability. What's 48?
correctness. If you're compiled on a non-ASCII system, 48 may not be the character code for 0.
Stan