ProgrammingHardTCS 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> int main(void) { int a = 57, b = 25; printf("%d %d %d", (a & b) | (a ^ b), a << 2, ~a & 0xFF); return 0; }

  1. A. 33 228 198
  2. B. 57 228 198
  3. C. 0 114 199
  4. D. 57 228 -58

Correct answer: B. 57 228 198

(a&b)|(a^b) equals a|b = 57; a<<2 = 228; ~a & 0xFF keeps the low byte of the complement = 198.

More C Programming questions

Exams that ask this topic