/*Example -1
Input number: 0
Binary value: 00000000
Output: Yes, all bits are unset
Example -2
Input number: 50
Binary value: 00110011
Output: No, all bits are not unset*/
#include <stdio.h>
int isallbitUNset();
int main(){
unsigned int n;
scanf("%d",&n);
if (isallbitUNset(n)){
printf("all bits are unset");
}
else{
printf("all bits are not unset");
}
}
int isallbitUNset(unsigned int no){
int loop, count=0;
for(loop=7;loop>=0;loop--){
//check, if there is any SET/HIGH bit
if(no & (1<<loop)){
count=1;
break;
}
}
if(count==0)
return 1;//true
else
return 0;//false
}
To embed this program on your website, copy the following code and paste it into your website's HTML: