Code for problem 49C.