← Logical Operators & the Ternary Operator

Ternary Max of Three

medium

Read three integers and print the largest, using a single expression built from two ternary operators – not an if/else if/else chain.

The trick is nesting: first decide whether a or b is bigger (a plain two-way ternary), then whichever one wins that comparison needs to be compared against c in turn. That’s two ternaries, one nested inside a branch of the other. Parenthesize generously – it costs nothing and makes the nesting unambiguous to a reader (including you, tomorrow).

Your solution

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

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution