ProgrammingHard
What is (1ULL << 40) % 1000 in C?
- A. 511
- B. 776
- C. 99
- 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
- For the signed integer -17, which expression gives the non-negative remainder modulo 5 in C?
- In 32-bit signed int arithmetic, what is the largest n such that the sum 1 + 2 + ... + n does not overflow?
- How many integers from 1 to 100 are divisible by 6 or by 9?
- With 32-bit unsigned int, what is 65536u 65536u?
- Exponentiation by squaring computes x^1000 with how many multiplications at most, counting squarings and the result multiplications?
- In ASCII, what is 'k' ^ 32 as a character?