Code

#include <stdio.h>

int toggleFifthBit(int n) {
    // Write your code here
    int temp_value =n;
    temp_value |= (1 << 5);
    if(temp_value == n){
        n &= ~(1 << 5);
    }else{
        n = temp_value;
    }
    
    return n;
}

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

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

8

Expected Output

40