cybersecurity · beginner · ~15 min
Aggregate the success of a sequence of calls.
Confirm that every step in a sequence of operations succeeded, so a mid-chain failure can't be silently ignored.
Implement int all_ok(const int *rcs, int n) that returns 1 if all n return codes are non-negative, else 0.
rcs: an array of n return codes the grader passes.n: the number of codes.Returns int: 1 if every rcs[i] >= 0, else 0.
all_ok({0, 1, 2}, 3) -> 1
all_ok({0, -1, 2}, 3) -> 0 (one failure)
An int array rcs of length n.
An int: 1 if every code is >= 0, else 0.
Any negative code yields 0.
int all_ok(const int *rcs, int n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.