pointers-memory · intermediate · ~15 min

Sum via pointer walking

Use pointer increment and two-pointer ranges (like C++ iterators).

Challenge

Implement long sum_walk(const int *begin, const int *end) that sums ints in the half-open range [begin, end). Walk via pointer arithmetic — do not take a separate length.

Starter code

#include <stddef.h>

long sum_walk(const int *begin, const int *end) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.