#include <stdio.h> #include <stdint.h> uint32_t update_register(uint32_t reg) { // Your logic here // Extract the 5 bit bitfield (bits 10-14): uint8_t tempreg = (reg & 0x7C00) >> 10; // Increment if extracted bitfield is less than 31 if(tempreg < 31){ tempreg += 1; } // Clear bits 10-14 in reg: reg &= ~(0x7C00); // OR the updated tempreg into reg at previous position: reg |= (tempreg << 10); 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