#include <stdio.h> #include <stdint.h> uint8_t modify_register(uint8_t reg) { int arr[4] = {2, 7, 3, 5}; int *ptr = arr; reg |= (1U << *ptr); // bit 2 reg |= (1U << *(++ptr)); // bit 7 reg &= ~(1U << *(++ptr)); // clear bit 3 reg ^= (1U << *(++ptr)); // toggle bit 5 return reg; } int main(void) { uint8_t reg; scanf("%hhu", ®); printf("%u", modify_register(reg)); return 0; }
Test Cases
Test Results
Expected Output
164