ProgrammingVery hardCompetitive coding (CP)
What is printed?
What is printed?
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint8_t v = 0x81;
v = (uint8_t)((v >> 1) | (v << 7));
printf("%d", v);
}- A. 64
- B. 192
- C. 224
- D. 129
Correct answer: B. 192
Rotating 10000001 right by one moves the low bit to the top, giving 11000000 = 192. Losing the wrapped bit gives 64, and rotating by two gives 224.
More C Programming questions
- How many times does the loop body run? c #include <stdio.h> int main(void) { unsigned mask = 0x2D, n = 0; for (unsigned s = mask; s; s =…
- Assume unsigned int is 32 bits. What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint32t a = 70000, b = 70000…
- What is printed? c #include <stddef.h> #include <stdio.h> int main(void) { sizet n = 3; int k = -2; printf("%zu %d", (sizet)(k + n), (n +…
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 0x06; uint8t r = 0; for (int i = 0; i < 8; i++) { r…
- What is printed? c #include <stdio.h> unsigned g(unsigned n) { return n ^ (n >> 1); } int main(void) { printf("%u %u", g(10), g(7)); }
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 12; uint8t y = (uint8t)-x; printf("%d", y); }