Adding solution for problem 29 in c.