Adding solution for problem 51 in c.