ProgrammingHardCompetitive coding (CP)
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
long long x = (1LL << 40) + 5;
printf("%d", (int)(x & 0xFFFFFFFFLL));
}- A. 0
- B. 4
- C. 5
- D. 6
Correct answer: C. 5
The mask keeps only the low 32 bits of x, which hold the 5, and the value 5 fits in an int. The 1 << 40 part is removed by the mask.
More C Programming questions
- What is printed? Assume int is 4 bytes. c #include <stdio.h> int main(void) { printf("%zu", sizeof('a')); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", ~5 & 0xF); }
- What is printed? c #include <stdio.h> int main(void) { unsigned char c = 254; int n = 0; while (++c) n++; printf("%d", n); }
- How many iterations does this binary search make to find 13 in the sorted array 0 to 15? Compute with the program. c #include <stdio.h>…
- n <= 10^5 values, each up to 10^9, must be summed. Which declaration is correct for the total?
- To test whether n = 10^12 is prime by trial division up to sqrt(n), which loop is correct?