You use char c = getch ();
Then int a = c-' 0 ';; For example, if you enter 8, then c='8', so c-'0'='8'-'0'=8.
Because the ASC code of the input number minus the ASC code of 0 is the corresponding number.