ProgrammingVery hardCompetitive coding (CP)
What is printed?
What is printed?
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint8_t x = 0x96;
uint8_t r = (uint8_t)((x << 3) | (x >> 5));
printf("%d", r);
}- A. 75
- B. 180
- C. 150
- D. 165
Correct answer: B. 180
Rotating 10010110 left by three gives 10110100 = 0xB4 = 180. The shifted-out top bits come back in through the right shift.
More C Programming questions
- What is printed? Assume signed char is 8 bits, two's complement. c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { long long x = (const long long )a, y =…
- What is printed? c #include <stdio.h> int calls = 0; int g(int a, int b) { calls++; return b ? g(b, a % b) : a; } int main(void) { int r =…
- How many ways are there to climb 20 steps taking 1 or 2 at a time? Compute with this exponential recursion. c #include <stdio.h> long long…
- What is printed? c #include <stdio.h> int calls = 0; int bs(int a, int lo, int hi, int k) { calls++; if (lo > hi) return -1; int m = lo +…
- What is printed? c #include <stdio.h> int main(void) { unsigned x = 0; int c = 0; for (unsigned i = 1; i <= 16; i++) { x = i; while (x) {…