finished c code