#include <stdio.h>
int toggleFifthBit(int n) {
// Write your code here
return n ^ (1<<5);
}
int main() {
int n;
scanf("%d", &n);
printf("%d", toggleFifthBit(n));
return 0;
}
Solving Approach
XOR with 1 toggles a bit, XOR with 0 leeps it the same. Shift a single 1 to position 5, inverting bit 5 and keeping all other bits the same.