#include <stdio.h> int main() { unsigned char reg; // 8-bit register (0-255) int bit_pos, mode; scanf("%hhu %d %d", ®, &bit_pos, &mode); if (mode == 1) reg |= (1 << bit_pos); // Set the bit else reg &= ~(1 << bit_pos); // Clear the bit printf("%u\n", reg); return 0; }
Test Cases
Test Results
Input
10 3 1
Expected Output
10