ProgrammingHardGATE CS · Competitive coding (CP)
What is printed? Assume unsigned long long is 64 bits.
What is printed? Assume unsigned long long is 64 bits.
#include <stdio.h>
int main(void) {
printf("%llu", (1ULL << 63) * 2);
}- A. 9223372036854775808
- B. 1
- C. 2
- D. 0
Correct answer: D. 0
2^63 times 2 is 2^64, which wraps to 0 in a 64-bit unsigned type. Halving the shift would give 2^63, which is the second option.
More C Programming questions
- How many positions differ between the two strings? Compute with this program. c #include <stdio.h> int main(void) { const char p =…
- What is printed? Assume unsigned long long is 64 bits. c #include <stdio.h> int main(void) { unsigned long long p = 4000000000ULL…
- What is printed? c #include <stdio.h> int main(void) { int x = 5; int p = &x; p = p << 2 | 1; printf("%d", x); }
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint32t x = ~0u >> 3; int c = 0; for (; x; x &= x - 1) c++…
- What is printed? c #include <stdio.h> unsigned long long g(int n) { if (n < 2) return 0; return g(n - 1) + g(n - 2) + 1; } int main(void)…
- int c = 0; for (int i = 0; i < 4; i++) for (int j = 0; j < i i; j++) c++; printf("%d", c); What is printed?