ProgrammingHardGATE CS · Competitive 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) {
    printf("%llu", (1ULL << 63) * 2);
}
  1. A. 9223372036854775808
  2. B. 1
  3. C. 2
  4. D. 0

Correct answer: D. 0

2^63 times 2 is 2^64, which wraps to 0 in a 64-bit unsigned type. Halving the shift would give 2^63, which is the second option.

More C Programming questions

Exams that ask this topic