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.
int program_status(int errors) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.