Exercise 5-2 and fixed getch()/ungetch() in Exercise 5-1