#include <stdint.h> #include <stdio.h> uint8_t set_clear(uint8_t reg, int pos, int mode) { if (mode == 1) return reg |= (1 << pos); else return reg &= ~(1 << pos); } int main() { uint8_t reg; int pos, mode; scanf("%hhu %d %d", ®, &pos, &mode); printf("%d\n", set_clear(reg, pos, mode)); return 0; }
Test Cases
Test Results
Input
10 3 1
Expected Output
10