← The Preprocessor: Macros & Conditional Compilation

Verbose Mode

hard

VERBOSE is #defined at the top of this file (with no value – just being defined at all is what #ifdef checks for). Wrap a debug printf in #ifdef VERBOSE / #endif so it prints before the normal output, exactly as described in the lesson’s example.

In a real project, VERBOSE (or a name like it) would typically be defined per build – present when compiling a debug version, absent from a release build – rather than hardcoded in the source like this. Here it’s fixed so the exercise has one deterministic, gradable behavior; the mechanism is identical either way.

Your solution

"Run" uses the sample stdin ("5"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution