ProgrammingHardIBM · Deloitte pattern

What is printed?

What is printed?
#define DEBUG 0
int main(void) {
#if DEBUG
    printf("debug mode\n");
#else
    printf("release mode\n");
#endif
    return 0;
}
  1. A. Compilation error: #if requires defined()
  2. B. debug mode
  3. C. release mode
  4. D. Both lines print

Correct answer: C. release mode

#if evaluates DEBUG as an integer constant expression (0, since it's literally defined as 0, not merely checked for existence with defined()); since 0 is falsy, the #else branch is compiled instead, printing "release mode".

More C Programming questions

Exams that ask this topic