#include <stdio.h> #include <stdint.h> #define BIT_FIELD_LENGTH 5 #define BIT_FIELD_START 10 #define BIT_FIELD_MASK (((1 << BIT_FIELD_LENGTH) - 1) << BIT_FIELD_START) uint32_t update_register(uint32_t reg) { // Your logic here uint32_t bit_field_value = (reg & BIT_FIELD_MASK) >> BIT_FIELD_START; if(bit_field_value < 31) { bit_field_value++; bit_field_value <<= BIT_FIELD_START; reg &= ~BIT_FIELD_MASK; reg |= bit_field_value; } return reg; } 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