Finished C version of program