Completed problem 16 in C