#include <stdio.h> #include <stdint.h> // Define bitwise macros here #define BIT_2 (2U) #define BIT_7 (7U) #define BIT_3 (3U) #define BIT_5 (5U) #define SET_BIT(reg,b) (reg|(1<<b)) #define CLEAR_BIT(reg,b) (reg&~(1<<b)) #define TOGGLE_BIT(reg,b) (reg^(1<<b)) uint8_t modify_register(uint8_t reg) { // Apply operations in order reg = SET_BIT(reg,BIT_2) ; reg =SET_BIT(reg,BIT_7) ; reg =CLEAR_BIT(reg,BIT_3) ; reg =TOGGLE_BIT(reg,BIT_5); return reg; } int main() { uint8_t reg; scanf("%hhu", ®); printf("%u", modify_register(reg)); return 0; }
Test Cases
Test Results
Input
0
Expected Output
164