Adding solution for problem 21 in c.