Completed problem 14 in C