basics · beginner · ~15 min
Use `if/else` to compare values.
Return the largest of three integers.
Implement int max3(int a, int b, int c) that returns the greatest of the three values. No main — the grader calls it.
Three int arguments. Values may repeat and may be negative.
The single largest int. If two or three are tied for the largest, return that value.
max3(1, 2, 3) -> 3
max3(5, 1, 4) -> 5
max3(-1, -2, -3) -> -1
max3(2, 2, 2) -> 2
Three int arguments a, b, c.
The largest of the three ints.
a, b, and c are 32-bit signed integers. No dynamic allocation.
int max3(int a, int b, int c) {
/* TODO */
return 0;
}
Using nested if-else branches that miss tie conditions where two or more arguments share the maximum value.
All three values equal, two values equal and strictly greater than the third, negative values, INT_MIN.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.