#include <stdio.h>
int main() {
unsigned int var = 2; //0010 if var = 8 1000 then bit is set
if((var & (1<<3)) == 0){ // 0010 & ((0001 << 3)=(1000))
// 0010 & (1000) == 0
printf("bit is not set");
}
else{
printf("bit is set");
}
int a = 0xA1 //1010 0001 //same just its 8bits of data
if ((a & (1 << 0)) == 0) {
printf("bit is not set");
} else {
printf("bit is set");
}
}
#if 0
int main(){
int a=6,b,c,d;// 0110
b=((a || (1<<3))); //delete a bit
printf("%d",b);
c=((a ^ (1<<3))); // add bit
printf("\n%d",c);
if((a & (1<<2))==0){ // check bit //((()))
printf("bit is not set");
}
else{
printf("bit is set");
}
}
#endif
To embed this program on your website, copy the following code and paste it into your website's HTML: