ProgrammingHardWipro · Cognizant pattern

What is printed?

What is printed?
#define CONCAT(a, b) a##b
int main(void) {
    int xy = 100;
    printf("%d", CONCAT(x, y));
}
  1. A. xy
  2. B. 0
  3. C. 100
  4. D. Compilation error: a##b is invalid syntax

Correct answer: C. 100

The ## operator pastes tokens together at preprocessing time: CONCAT(x, y) becomes the single identifier `xy`, which the compiler then sees as a reference to the variable xy = 100.

More C Programming questions

Exams that ask this topic