ProgrammingHardGATE CS · Competitive coding (CP)
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
unsigned x = 0xDEADu;
printf("%u", (x >> 3) & 0xFu);
}- A. 13
- B. 6
- C. 7
- D. 5
Correct answer: D. 5
0xDEAD >> 3 is 0x1BD5, and masking the low nibble gives 5. Using the bits starting at position 4 would give a different nibble.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { unsigned a = 0x12345678u, b = 0x12345600u, x = a ^ b; int c = 0; while (x) { c += x…
- What is printed? Assume uint8t is 8 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint8t acc = 0; uint8t v[] = {200…
- What is printed? Assume uint32t is 32 bits. c #include <stdint.h> #include <stdio.h> int main(void) { uint32t a = 70000, b = 70000…
- What is printed? c #include <stdio.h> int main(void) { long long a = 1LL << 40; int b = (int)(a >> 20); printf("%d", b); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {4, 2, 5, 1}; for (int i = 0; i < 3; i++) printf("%d ", a[i] > a[i + 1] ?…
- How many pairs (i, j) with i < j have a[i] XOR a[j] equal to 5 for a = {1, 2, 3, 4}? Compute with this program. c #include <stdio.h> int…