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.
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.