finished c solution.