8. Toggle the Bit in an 8-bit Register

In your firmware, you want to toggle a specific bit in an 8-bit register. Toggle means to invert the bit: if 1 → 0, and if 0 → 1.
Use 0-based indexing for bit positions (0 = LSB, 7 = MSB).
 

Example 1

Input: reg = 0b00000110, pos = 1 
Output: 0b00000100


Example 2

Input: reg = 0b00000000, pos = 3 
Output: 0b00001000


Example 3

Input: reg = 0b00001111, pos = 3 
Output: 0b00000111


 

Loading...

Input

6 1

Expected Output

4