basics · beginner · ~15 min
Produce a function the compiler accepts and links.
Write a clean, warning-free function the compiler can turn into an object file.
Implement int max2(int a, int b) that returns the larger of the two values (return either when they are equal). No main — the grader calls it.
Two ints a and b.
Returns the larger value, as an int.
max2(3, 7) -> 7
max2(9, 2) -> 9
max2(5, 5) -> 5
max2(-1, -4) -> -1
Two ints a and b.
The larger of a and b, as an int.
int max2(int a, int b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.