Problem 9

Solution for problem 9 in CPP.