C solution for problem 9
C solution to problem 21