Converted Pseudocode for Proj 2 into C