Practice ยท 1 of 4
Walk, Don't Index
Implement two sums over an int array using ONLY pointer arithmetic โ
no [ ] indexing anywhere in your implementation:
``c
long long sum_walk(const int *a, size_t n); /* forward walk */
long long sum_reverse(const int *a, size_t n); /* walk from one-past-end backwards */
`
Both return 0 for NULL or n == 0. Use (a + n)` as the one-past-the-end pointer.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Address Walking Gym