#include <stdio.h> #include <stdint.h> // Define macros here #define SetEnable(reg,value) (reg|= (value << 0)& 0x1) #define SetMode(reg,value) (reg|= (value << 1)& 0x6) #define SetSpeed(reg,value) (reg|= (value << 3)&0x38) uint16_t build_register(uint8_t enable, uint8_t mode, uint8_t speed) { uint16_t reg = 0x0; SetEnable(reg,enable); SetMode(reg,mode); SetSpeed(reg,speed); return reg; } int main() { uint8_t enable, mode, speed; scanf("%hhu %hhu %hhu", &enable, &mode, &speed); uint16_t reg = build_register(enable, mode, speed); printf("%u", reg); return 0; }
Test Cases
Test Results
Input
1 2 4
Expected Output
37