ProgrammingHardGATE CS · TCS NQT

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    unsigned a = 0xC, b = 0xA, c = 0x9;
    unsigned m = (a & b) | (b & c) | (a & c);
    printf("%u", m);
}
  1. A. 12
  2. B. 14
  3. C. 8
  4. D. 13

Correct answer: C. 8

Each bit of m is 1 when at least two of the three inputs have that bit set. Only bit 3 is set in two or more inputs, so m = 8.

More C Programming questions

Exams that ask this topic