cybersecurity · beginner · ~15 min
Write the canonical bounds check.
Implement int in_bounds(int idx, int n) returning 1 if idx is a valid index into an n-element array (0 <= idx < n).
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.