ProgrammingHardCompetitive coding (CP)

What is printed? Assume unsigned long long is 64 bits.

What is printed? Assume unsigned long long is 64 bits.
#include <stdio.h>
int main(void) {
    unsigned long long v = 0xFFULL << 56;
    printf("%llu", v >> 60);
}
  1. A. 15
  2. B. 255
  3. C. 240
  4. D. 14

Correct answer: A. 15

0xFF shifted left by 56 fills the top byte, and shifting right by 60 keeps the top nibble, 0xF = 15. The value 240 would be the top byte before the shift.

More C Programming questions

Exams that ask this topic