Adding solution for problem 30 in c.