Skip to main content

Macro Clamp

Challenge on lesson: Checkpoint: Preprocessor

Define #define CLAMP(v, lo, hi) as a do-while(0) statement macro that modifies v IN PLACE to lie within [lo, hi], and implement int percent_band(int v) returning 0 when v <= 0, 100 when v >= 100, and v otherwise.

Difficulty: beginner

Back to lesson: Checkpoint: Preprocessor