int sum(int vec[], int dim) { int i, total = 0; for (i = 0; i < dim; i++) { total += vec[i]; } return total; }