ProgrammingModerateTCS NQT · Wipro

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", 1 << 30 >> 28);
}
  1. A. 2
  2. B. 4
  3. C. 8
  4. D. 16

Correct answer: B. 4

Both shifts are applied left to right on int values that stay in range: 1 << 30 = 2^30, then >> 28 gives 4.

More C Programming questions

Exams that ask this topic