Program To Check Power of 2

#include<stdio.h> 
void main() 
{
        int n,count; 
        printf("Enter the number to be checked:"); 
        scanf("%d",&n); 
        while((n&(n-1))==0) 
       { 
                 printf("number is power of 2"); 
                 break; 
       }
       printf("number is not power of 2"); 
}

No comments:

Post a Comment