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 p = 4000000000ULL * 4000000000ULL;
    printf("%llu", p);
}
  1. A. 0
  2. B. 16000000000000000000
  3. C. 1600000000000000000
  4. D. 4000000000

Correct answer: B. 16000000000000000000

The product is 1.6 * 10^19, which is below 2^64 = 1.8446 * 10^19, so it fits in an unsigned long long exactly. Shifting by one digit gives the third option.

More C Programming questions

Exams that ask this topic