Adding solution for problem 49 in c.