networking · beginner · ~15 min

HTTP status class

Bucket a status into its class.

Challenge

Implement int status_class(int code) returning the leading digit of an HTTP status (e.g. 404 -> 4, 200 -> 2). Return 0 for codes outside 100..599.

Starter code

int status_class(int code) {
    /* TODO */
    return 0;
}

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