basics · beginner · ~15 min
Combine comparisons with if/else.
Return the largest of three integers.
Implement int max3(int a, int b, int c) that returns the largest of the three values. No main — the grader calls it.
Three ints a, b, and c.
Returns the maximum of the three, as an int.
max3(3, 1, 2) -> 3
max3(1, 5, 2) -> 5
max3(1, 2, 9) -> 9
max3(-3, -1, -2) -> -1
Three ints a, b, and c.
The largest of the three, as an int.
int max3(int a, int b, int c) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.