#include <stdio.h> #include <stdint.h> #define BIT(n) (1u << (n)) #define SET_BITS_MASK (BIT(2) | BIT(7)) #define CLEAR_BITS_MASK BIT(3) #define TOGGLE_BITS_MASK BIT(5) uint8_t modify_register(uint8_t reg) { reg |= SET_BITS_MASK; // Set bits 2 and 7 reg &= (uint8_t)~CLEAR_BITS_MASK; // Clear bit 3 reg ^= TOGGLE_BITS_MASK; // Toggle 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