c version of sum