basics · beginner · ~15 min
Mirror the max logic for the minimum.
Return the smaller of two integers.
Implement int min2(int a, int b) that returns the smaller of the two values (return either when they are equal). No main — the grader calls it.
Two ints a and b.
Returns the smaller value, as an int.
min2(3, 7) -> 3
min2(9, 2) -> 2
min2(-1, -4) -> -4
Two ints a and b.
The smaller of a and b, as an int.
int min2(int a, int b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.