#include <stdio.h> #include <stdint.h> uint32_t extract_even_bits(uint32_t reg) { uint8_t i = 0, ii = 0; uint8_t position = 0; uint32_t outreg = 0; while(i < 32){ if((reg >> i) & 1) outreg = outreg|(1U << ii); i = i + 2; ii = ii + 1; } return outreg; } int main() { uint32_t reg; scanf("%u", ®); printf("%u", extract_even_bits(reg)); return 0; }
Test Cases
Test Results
Input
85
Expected Output
15