ProgrammingVery hardProduct company OA

What is printed?

What is printed?
#define VAR(n) v##n
#define PRINT(n) printf("%d ", VAR(n))
int v1 = 10, v2 = 20, v12 = 30;
PRINT(1); PRINT(1 + 1); PRINT(12);
  1. A. 10 11 30
  2. B. Compilation error
  3. C. 10 12 30
  4. D. 10 20 30

Correct answer: A. 10 11 30

## pastes only the adjacent tokens: VAR(1 + 1) becomes v1 + 1, which is 11, not v2. The preprocessor never evaluates 1 + 1. PRINT(12) pastes into the single identifier v12.

More C Programming questions

Exams that ask this topic