Code for problem 21B.