ProgrammingHardTCS NQT · Infosys pattern

What is printed?

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

Correct answer: A. 100

The ## operator pastes the two argument tokens together at the TEXT level before compilation, so CONCAT(x, y) becomes the single identifier xy — which happens to be the variable already declared with value 100.

More C Programming questions

Exams that ask this topic