wap to check whether an integer is a power of 2..



#include<stdio.h>
main()
{
int n,i;
printf("\nenter the number\n");
scanf("%d",&n);
i=n-1;
if((n&i)==0)
   printf("\ninteger is a power of 2\n");
else
   printf("\ninteger is not a power of 2\n");
}




No comments:

Post a Comment

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...