When you read a character,
scanf("%c",&t);
there's a newline left behind in the input stream which causes the subsequent scanf() to skip input in the loop.
Note that getch()
is non-standard function. You can use getchar()
instead.
Or Change it to:
scanf(" %c",&t);
Notice the space in the format specifier which ensures all the whitespaces are skipped by scanf() before reading a character for %c
.