#include <stdio.h> unsigned int toggleFifthBit(int n) { return ((1<<5)^n); /* 1<<5: This will generate binary: 0010 0000 Example: n=10 Binary 0000 1010 0000 1010 0010 0000 ^(XOR operation) is used for toggling bits. 0010 1010 */ } int main() { int n; scanf("%d", &n); printf("%d", toggleFifthBit(n)); return 0; } //0000 1010 //0010 0000 //0010 1010
Test Cases
Test Results
Input
8
Expected Output
40