But beware that typing in say 123456789012345678901234567890 will generate numeric overflow, but scanf will still claim success and give you some modulo-n result.

If this is a problem, use fgets() to read a line of input, then strtol() to convert from a string to a long integer. This also sets errno in case of overflow (of a long), then you can range-check it for an integer (or whatever the valid range is).