#include <stdio.h> int toggleFifthBit(int n) { return n^0x20; } int main() { int n; scanf("%d", &n); printf("%d", toggleFifthBit(n)); return 0; }
Here I have used 0x20 instead of 1<<5
Because answer for 1<<5 is 0x20
1--->binary-->00000001
1 << 5--->binary-->00100000
00100000---->hexadecimal--->0x20
Test Cases
Test Results
Input
8
Expected Output
40