Completed problem 2 in C, as well as added comments