Contact Learn C
Copy

Program 348 : Check whether all bits of a number are 1

Program 348 : Check whether all bits of a number are 1
 
#include<stdio.h>
main()
{
 int num,flag=1,temp;
 printf("Enter Number to know whether all bits of number are one\n");
 scanf("%d",&num);
 temp=num;
 while(num>1)
 {
  if(num%2==0)
  {
   flag=0;
   break;
  }
  else
  {
   num/=2;
  }
 }
 
 if(flag==1)
 printf("%d have all bits as 1\n",temp);
 else
 printf("%d doesn't have all bits as 1\n",temp);
}
Explanation:
//Coming Soon

Output: 

Check whether all bits of a number are 1

Check whether all bits of a number are 1





 
Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide