basics · beginner · ~15 min
Iterate an array by index.
Implement long array_sum(const int *a, int n) returning the sum of the first n elements.
long array_sum(const int *a, int n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.