Adding solution for problem 24 in c.