Code

#include <stdio.h> 

// Write a C program to toggle the 5th bit (0-based index) of a given integer.

// The program should take an integer N as input.
// It should toggle the 5th bit of N 
// Note: The 5th bit is at position 5(0-based indexing).

int toggle_bit5(int n){
    return n^(1 << 5);
}


int main(){

    int n; 
    scanf("%d",&n); 
    printf("%d",toggle_bit5(n)); 
    return 0;
}

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

8

Expected Output

40