← Functions & Pass-by-Value vs. Pass-by-Reference

Divide With Remainder

medium

divmod needs to hand back two results from one call – a quotient and a remainder – and a C function can only return one value. Complete it using the two pointer out-parameters quotient and remainder: write each result through its pointer rather than returning anything.

The arithmetic itself is just / and %; the exercise is entirely about the out-parameter mechanics. Note the last sample case: since C99, / truncates toward zero and % follows it, so -17 / 5 is -3 (not -4) and -17 % 5 is -2 (not 3) – this is guaranteed by the standard, not a compiler quirk, so you can rely on a / b and a % b giving you these exact values without any special-casing.

Your solution

"Run" uses the sample stdin ("17 5"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution