Skip to content

Instantly share code, notes, and snippets.

@faisal95bd
Created August 23, 2022 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faisal95bd/45e1c82c0e747f2538861f9e6d91b83f to your computer and use it in GitHub Desktop.
Save faisal95bd/45e1c82c0e747f2538861f9e6d91b83f to your computer and use it in GitHub Desktop.
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