cybersecurity · beginner · ~15 min

Index in bounds?

Write the canonical bounds check.

Challenge

Implement int in_bounds(int idx, int n) returning 1 if idx is a valid index into an n-element array (0 <= idx < n).

Starter code

int in_bounds(int idx, int n) {
    /* TODO */
    return 0;
}

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