Solution for Program 5.