#include <stdio.h>
void print_binary(unsigned int number);
int main() {
printf("Bitwise Toggle a particular bit!\n");
unsigned int n,pos;
printf("Enter a number\n");
scanf("%x",&n);
printf("The Entered number is %x ",n);
print_binary(n);
printf("\n");
printf("Which bit u need to set\n");
scanf("%d",&pos);
printf("position bit %d\n",pos);
//Logic to clearing the particular bit is
n = n ^ (1<<pos);
printf("clearing the bit at the position %d\n",pos);
print_binary(n);
return 0;
}
void print_binary(unsigned int number)
{
if (number >> 1) {
print_binary(number >> 1);
}
putc((number & 1) ? '1' : '0', stdout);
}
To embed this program on your website, copy the following code and paste it into your website's HTML: