text: Program to toggle K | C program to toggle K - th bit of a number N ; Function to toggle the kth bit of n ; Driver code
code: #include <stdio.h> NEW_LINE int toggleBit ( int n , int k ) { return ( n ^ ( 1 << ( k - 1 ) ) ) ; } int main ( ) { int n = 5 , k = 2 ; printf ( " % d STRNEWLINE " , toggleBit ( n , k ) ) ; return 0 ; }