ProgrammingHardGATE CS · Campus placements
What does (unsigned int)(-1) % 10 evaluate to on a platform with a 32-bit unsigned int?
- A. 9
- B. 4
- C. 5
- D. 1
Correct answer: C. 5
(unsigned int)(-1) is 4294967295, and its last digit is 5, so the remainder is 5. Applying the negation after the modulo would give a different answer.
More C Programming questions
- How many ways are there to write 5 as an unordered sum of 1s and 2s?
- void rev(char s) { char e = s + strlen(s) - 1; while (s < e) { char t = s; s++ = e; e-- = t; } } After rev("abcde") runs on a writable…
- Which algorithm finds the maximum subarray sum of an array of n = 10^6 ints in time within a typical 1 second contest limit?
- char s = "hello"; What is strlen(s + 2)?
- int x = 1, y = 2, z = 3; int ptrs[3] = {&x, &y, &z}; What is ptrs[1] + ptrs[2]?
- printf("%d", 0x7FFFFFFF == 2147483647); What is printed?