#include <stdio.h> #include <stdint.h> typedef union{ uint32_t four_byte; struct{ unsigned int first_field :10; unsigned int target :5; unsigned int reserved :17; }bits; } Mystruct; uint32_t update_register(uint32_t reg) { // Your logic here Mystruct long_reg; long_reg.four_byte = reg; if(long_reg.bits.target < 31){ long_reg.bits.target ++; } return long_reg.four_byte; } int main() { uint32_t reg; scanf("%u", ®); uint32_t updated = update_register(reg); printf("%u", updated); return 0; }
Test Cases
Test Results
Input
15360
Expected Output
16384