C Programming Code Examples C > Bitwise Operators Code Examples C Program to Count Number of bits set to 0 in an Integer C Program to Count Number of bits set to 0 in an Integer #include <stdio.h> #define j_bits_int (8*sizeof(int)) int count_unset(int); int main() { int i, j, sj, res, count = 0; printf("\nEnter the number"); scanf("%d", &j); /* * Check each bit whether the bit is set or unset * Uses >> and & operator for checking individual bits */ for (i = 0;i <= j_bits_int;i++) { sj = j >> i; res = sj & 1; if (res == 0) count++; } printf("%d", count); }