ProgrammingVery hardCompetitive coding (CP)

What is printed? Assume uint8t is 8 bits.

What is printed? Assume uint8_t is 8 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
    uint8_t x = 0x0F;
    uint8_t r = (uint8_t)((x >> 2) | (x << 6));
    printf("%d", r);
}
  1. A. 195
  2. B. 3
  3. C. 60
  4. D. 240

Correct answer: A. 195

Rotating 00001111 right by two gives 11000011 = 0xC3 = 195. The low bits shifted out reappear at the top through the left shift.

More C Programming questions

Exams that ask this topic