Code for problem 77C.