ProgrammingVery hard
unsigned char s = 0; for (int i = 1; i <= 100; i++) s += i; printf("%d", s); What is printed?
- A. 186
- B. 5050
- C. 58
- D. 122
Correct answer: A. 186
The sum 5050 wraps modulo 256 on each addition into an unsigned char. 5050 mod 256 = 186.
More C Programming questions
- What is (1ULL << 40) % 1000 in C?
- 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?