Adding solution for problem 47 in c.