#include <stdio.h>
#include <stdint.h>
uint32_t extract_even_bits(uint32_t reg) {
uint32_t result = 0;
int current_bit_position = 0;
for (int i = 0; i < 32; i += 2) {
// Extract the even-positioned bit (0, 2, 4, ..., 30)
// using a mask and right-shifting the register
uint32_t even_bit = (reg >> i) & 1;
// Shift the extracted bit to the appropriate position in the result
result |= (even_bit << current_bit_position);
current_bit_position++;
}
return result;
}
int main() {
uint32_t reg;
scanf("%u", ®);
printf("%u\n", extract_even_bits(reg));
return 0;
}
Input
85
Expected Output
15