Skip to content

Instantly share code, notes, and snippets.

Created August 23, 2022 06:29
What would you like to do?
Detect Power of Two
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);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment