C solution to problem 7
C solution problem 8