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);
}- A. 195
- B. 3
- C. 60
- 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
- How many set bits does this loop count in 0xFFFF0000? c #include <stdio.h> int main(void) { unsigned x = 0xFFFF0000u; int c = 0; while (x)…
- What is printed? Assume unsigned int is 32 bits. c #include <stdio.h> int main(void) { unsigned a = 65536u; printf("%u", a a); }
- What is printed? c #include <stdio.h> int main(void) { printf("%d", sizeof(char) - 2 > 0); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {-2, 1, -3, 4, -1, 2, 1, -5, 4}; int best = a[0], cur = a[0]; for (int i…
- How many subarrays of {1, -1, 2, -2, 3} have sum zero? Compute with this program. c #include <stdio.h> int main(void) { int a[] = {1, -1…
- What is printed? c #include <stdio.h> int pc(unsigned n) { return n ? (int)(n & 1u) + pc(n >> 1) : 0; } int main(void) { printf("%d"…