Solution to problem 1 in c.