Code for problem 45A.