#include <stdio.h> #include <stdint.h> uint32_t set_baud_rate(uint32_t reg, uint8_t baud) { // Your code here uint32_t mask; if(baud<0){ return 0; } mask=(( 1U << 4)-1 << 8); /// for set lenght reg&= ~mask; // clear reg return reg |= (baud<<8)&mask; //postion shift } 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