Completed problem 12 in C