ProgrammingVery hardTCS NQT · Infosys · 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)? #include <stdio.h> #define SQ(x) x * x #define MAX(a, b) ((a) > (b) ? (a) : (b)) int main(void) { int a = 4, b = 2; printf("%d %d", SQ(a + b), MAX(a, b) * 2); return 0; }
- A. 20 8
- B. 14 12
- C. 36 8
- D. 14 8
Correct answer: D. 14 8
SQ(a+b) expands textually to a + b * a + b = 14, not (a+b)². MAX is fully parenthesised so MAX(a,b)*2 = 8.
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)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int…