#include <stdio.h> #include <stdint.h> // Define bitwise macros here #define Set_Bit_2 1<<2 #define Set_Bit_7 1<<7 #define Clear_Bit 1<<3 #define Toggle_Bit 1<<5 uint8_t modify_register(uint8_t reg) { // Apply operations in order if((reg & Set_Bit_2) == 0) { reg |= Set_Bit_2; } if((reg & Set_Bit_7) == 0) { reg |= Set_Bit_7; } if((reg & Clear_Bit) != 0) { reg = reg & ~(Clear_Bit); } reg = reg^Toggle_Bit; 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