Completed problem 17 in C