ProgrammingVery hardIBM · Deloitte · Product Company SDE

What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs aligned to their widest member with no packing pragma)? #include <stdio.h> int main(void) { #define STR(x) #x #define XSTR(x) STR(x) #define VERSION 7 printf("%s %s", STR(VERSION), XSTR(VERSION)); return 0; }

  1. A. VERSION VERSION
  2. B. VERSION 7
  3. C. 7 VERSION
  4. D. 7 7

Correct answer: B. VERSION 7

STR uses the # operator to stringify its argument literally, before VERSION is expanded, giving "VERSION"; XSTR expands VERSION to 7 first (one extra macro layer) and then stringifies that, giving "7".

More C Programming questions

Exams that ask this topic