ProgrammingVery hardGATE CS · Competitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned a = 0xB6, b = 0x3C;
    printf("%u", a & ~b);
}
  1. A. 138
  2. B. 130
  3. C. 66
  4. D. 131

Correct answer: B. 130

~b keeps every bit outside 0x3C, and ANDing with a keeps the bits of a that are not in b. 0xB6 & 0xC3 = 0x82 = 130.

More C Programming questions

Exams that ask this topic