Skip to content

Instantly share code, notes, and snippets.

@faisal95bd
Created August 23, 2022 06:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Detect Power of Two
#include<stdio.h>
int main() {
int num;
printf("Enter a positive nonzero integer\n");
scanf("%d", &num);
if(num && ((num & (num-1)) == 0)){
printf("Yes", num);
} else {
printf("No", num);
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment