#include <stdio.h> #include <stdint.h> // Function to clear (set to 0) a specific bit uint8_t clearBit(uint8_t reg, int pos) { return reg & ~(1 << pos); } int main() { uint8_t reg; int pos; scanf("%hhu %d", ®, &pos); if (pos < 0 || pos > 7) { printf("Invalid bit position\n"); return 1; } uint8_t result = clearBit(reg, pos); printf("%u\n", result); return 0; }
Test Cases
Test Results
Input
7 0
Expected Output
6