man scanf:
RETURN VALUE
On success, these functions return the number of input items successfully matched
and assigned; this can be fewer than provided for, or even zero, in the event of
an early matching failure.
man getchar:
RETURN VALUE
fgetc() and getchar() return the character read as an unsigned char cast to an int
or EOF on end of file or error.
There are a lot of inconsistencies with C functions, so important to check the man pages so you can handle them correctly.
Your call to getchar isn't quite correct either, pressing the 1 key would print out 49, which is the ASCII codepoint for the 1 char.