ProgrammingHardCompetitive coding (CP)

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    long long x = (1LL << 40) + 5;
    printf("%d", (int)(x & 0xFFFFFFFFLL));
}
  1. A. 0
  2. B. 4
  3. C. 5
  4. D. 6

Correct answer: C. 5

The mask keeps only the low 32 bits of x, which hold the 5, and the value 5 fits in an int. The 1 << 40 part is removed by the mask.

More C Programming questions

Exams that ask this topic