basics · beginner · ~15 min
Model exit-code conventions.
Model the exit-code convention: 0 means success, non-zero means failure.
Implement int program_status(int errors) that returns the status code a program would exit with: 0 when errors is 0, otherwise 1. No main — the grader calls it.
A single int errors (a count of errors, >= 0).
Returns 0 if errors is 0, otherwise 1.
program_status(0) -> 0 (success)
program_status(1) -> 1 (failure)
program_status(5) -> 1
A single int errors (>= 0).
0 when errors is 0, otherwise 1.
errors is an integer representing the count of recorded errors (>= 0).
int program_status(int errors) {
/* TODO */
return 0;
}
Confusing standard Unix exit codes: 0 indicates success, non-zero indicates failure.
errors == 0 (success status 0), errors == 1, errors > 1.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.