Completed problem 21 in C