C-Program to check whether a number is power of 2 or not


#include <stdio.h>
#include <string.h>

main()
{
  int number;

  printf("Enter the number\n");
  scanf("%d",&number);
  if(!(number&(number-1)))
      printf("%d is a power of 2\n",number);
  else
      printf("%d is not a power of 2\n",number);

}

Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig