EmbLogic's Blog

Write a program to find particular no. is power of two or not?

CODE:

#include<stdio.h>
int main()
{
int n;
printf(“Enter a value\n”);
scanf(“%d”,&n);
if((n &(n-1))==0)
printf(“no. is power of 2\n”);
else
printf(“no. is not power of 2\n”);
return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>