C Programming Code Examples C > Bitwise Operators Code Examples C Program to Check if All the Bits of a given Integer is One(1) C Program to Check if All the Bits of a given Integer is One(1) #include <stdio.h> int all_bits_one(int); int count = 0; void main() { int j; printf("enter the number:"); scanf("%d", &j); j++; all_bits_one(j); if (count) { printf("false"); } else { printf("true"); } } /* checks whether all bits are 1 */ int all_bits_one(int x) { if (x == 1) return 0; if (x % 2 != 0) { count++; } else { x = x / 2; all_bits_one(x); } }