Toggle the Bit in an 8-bit Register

Code

#include <stdio.h>
int main() {
    int reg, pos, result;

    
    scanf("%d %d", &reg, &pos);

    
    result = reg ^ (1 << pos);

    
    printf("%d", result);

    return 0;
}

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

6 1

Expected Output

4