pointers-memory · beginner · ~15 min

All zero?

Verify a buffer is zeroed.

Challenge

Implement int all_zero(const int *a, int n) returning 1 if every one of the first n elements is 0, else 0.

Starter code

int all_zero(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.