Not every unsuccessful operation is a programming mistake. A request can be validly rejected: a negative amount, an unavailable place, or a denominator of zero. A small function can return a boolean status while delivering a successful value through an output reference.
#include <iostream>
bool halfEven(int value, int& result) {
if (value % 2 != 0) return false;
result = value / 2;
return true;
}
int main() {
int half = -1;
bool accepted = halfEven(10, half);
std::cout << std::boolalpha << accepted << ' ' << half << '\n';
}
The boolean and the output reference have different jobs. The boolean tells the caller whether to use a new answer. The reference lets the function put that answer into the caller's variable, but only after validation succeeds. The caller initializes its variable first and checks the status before treating the value as a new result. On failure, this function leaves the output unchanged. That promise makes callers easier to reason about.
A status is different from an assertion. Odd input is an expected possibility here, not a broken internal invariant. The program should remain in control and decide what message or next action is appropriate.
The task's splitEvenly divides a nonnegative item count among a positive number of people, but accepts only exact divisions. Its guards are supplied in the safe order: reject a zero or negative divisor before using % or /. You complete the success path, then replace a placeholder status message in a separate helper. The rejection probe also verifies the unchanged output value. No interactive input is needed; fixed calls let you examine both paths every time you Run.
Edit main.cpp; the supplied Console probes already call your code.
splitEvenly: assign the quotient to each and return true. Expect Split: true 6; the zero-divisor probe remains Rejected: false 99.statusText return "accepted" for true and "rejected" for false. Expect Status: rejected accepted.Use Run to inspect the Console, then Submit to check your work.