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; }
- A. VERSION VERSION
- B. VERSION 7
- C. 7 VERSION
- 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
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…