ProgrammingHard

What is (1ULL << 40) % 1000 in C?

  1. A. 511
  2. B. 776
  3. C. 99
  4. D. 1000

Correct answer: B. 776

2^40 = 1099511627776 fits easily in unsigned long long, so the % is exact and keeps the last three digits, 776. Shortcut: 2^10 = 1024 leaves 24 mod 1000, and 24^4 = 331776 also ends in 776.

More C Programming questions

Exams that ask this topic