🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Files and Preprocessor: all 10 questions

Quiz: Files and Preprocessor · Question 9 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
#define DEBUG 1
int main(void) {
#if DEBUG
    printf("on ");
#else
    printf("off ");
#endif
    printf("done\n");
    return 0;
}
  1. A.off done
  2. B.on done
  3. C.on off done
  4. D.done
Answer & explanation

Correct answer: on done

The preprocessor keeps only the #if branch because DEBUG is 1; the #else part never reaches the compiler.

Can you get the rest right without peeking?

Take the timed Quiz: Files and Preprocessor quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →