ProgrammingHardCompetitive coding (CP)
What is printed? The reverse of the binary digits of 13 (1101) is taken as an integer.
What is printed? The reverse of the binary digits of 13 (1101) is taken as an integer.
#include <stdio.h>
int main(void) {
unsigned x = 13, r = 0;
while (x) { r = (r << 1) | (x & 1u); x >>= 1; }
printf("%u", r);
}- A. 13
- B. 11
- C. 7
- D. 14
Correct answer: B. 11
Reading 1101 from the low end gives 1011 = 11. Printing the original value would give 13.
More C Programming questions
- How many occurrences of the two-letter string "ab" are in "abcabab"? Count them with this program. c #include <stdio.h> int main(void) {…
- What is printed? c #include <stdio.h> int main(void) { int c = 0; switch ('b') { case 'a': c++; case 'b': c += 10; case 'c': c += 100…
- How many nodes are at depth 2 in a perfect binary tree of depth 3 (the root is depth 0)? The program counts them recursively. c #include…
- What is printed? Each struct has an int a and an int b. c #include <stdio.h> #include <stdlib.h> struct P { int a, b; }; int cmp(const…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 11, y = x & (x + 1); printf("%u", y); }
- What is printed? Assume int is 4 bytes. c #include <stdio.h> int main(void) { int (p)[3] = 0; printf("%zu", sizeof p); }