Solved problem 13 in C