Power of 2 Program in C | c program to test given number is power of two or not

Spread the love

Number is power of two Program :

  1. #include<stdio.h>
  2. main()
  3. {
  4. int i,var;
  5. printf(“Eneter a integer : “);
  6. scanf(“%d”,&i);
  7. var=1;
  8. Label: var=var*2;
  9. if(var<i)
  10. goto Label;
  11. if(var==i)
  12. printf(“given integer is power of 2 \n);
  13. else
  14. printf(“input is not a power of 2\n);
  15. }

Output :

number-is-power-of-two

Venkat

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

Leave a Reply