linux-sysprog · beginner · ~15 min

Seconds remaining on a timer

Compute a countdown without underflow.

Challenge

Implement int alarm_remaining(int set_seconds, int elapsed) returning how many seconds are left before an alarm fires (never negative).

Starter code

int alarm_remaining(int set_seconds, int elapsed) {
    /* TODO */
    return 0;
}

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