Skip to main content

Practice ยท 2 of 3

Statement Macro

Define #define INCREMENT_IF(var, cond) as a do-while(0) statement macro that increments var only when cond is true. It must be usable as a single statement (with a trailing semicolon) even inside if/else.

Difficulty: beginner

Back to lesson: Practice: Organization Practice