All submissions

Clear the Bit in an 8-bit Register

Code

#include <stdio.h>

// Function to clear a bit at position 'pos'
unsigned char clearBit(unsigned char reg, int pos) {
    return reg & ~(1 << pos);
}

int main() {
    unsigned char reg;   // 8-bit register (0–255)
    int pos;             // bit position (0–7)

    // Input: register value and bit position
    scanf("%hhu %d", &reg, &pos);

    // Call function
    unsigned char result = clearBit(reg, pos);

    // Output the modified register
    printf("%d\n", result);

    return 0;
}

Solving Approach

 

 

 

Loading...

Input

7 0

Expected Output

6