Clamp a Number
Easy · Control Flow
Clamp means: if n is below lo, return lo; if it is above hi, return hi; otherwise return n. Assume lo <= hi.
Write Clamp(n, lo, hi) that clamps n to [lo, hi].
Next: Minutes to Clock
Easy · Control Flow
Clamp means: if n is below lo, return lo; if it is above hi, return hi; otherwise return n. Assume lo <= hi.
Write Clamp(n, lo, hi) that clamps n to [lo, hi].
Next: Minutes to Clock