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

Spread the love

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 2n);
  15. }

Output :

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply