🎙 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 2 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
#define DOUBLE(x) x + x
int main(void) {
    printf("%d", DOUBLE(3) * 2);
    return 0;
}
  1. A.12
  2. B.9
  3. C.6
  4. D.18
Answer & explanation

Correct answer: 9

It expands to 3 + 3 * 2 = 3 + 6 = 9. The macro needed brackets: ((x) + (x)).

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 →