#include <stdio.h> #include <stdint.h> uint32_t set_baud_rate(uint32_t reg, uint8_t baud) { // Your code here uint32_t pos1,pos; for(pos=8, pos1=0; pos<=11 ; pos++,pos1++) { uint32_t bit1 = (reg>>pos)&1; uint32_t bit2 = (baud>>pos1)&1; if(bit1 != bit2) reg = reg^(1<<pos); } return reg; } int main() { uint32_t reg; uint8_t baud; scanf("%u %hhu", ®, &baud); printf("%u", set_baud_rate(reg, baud)); return 0; }
Test Cases
Test Results
Input
0 10
Expected Output
2560