Code

#include <stdio.h>

int toggleFifthBit(int n) {
    // Write your code here
    n ^= (1<<5);
    return n;
}

int main() {
    int n;
    scanf("%d", &n);
    printf("%d", toggleFifthBit(n));
    return 0;
}

Solving Approach

For toggling a bit xor is used and whatever bit want to toggle that bit position i.e 1 << position of toggling bit.

 

Upvote
Downvote
Loading...

Input

8

Expected Output

40