C Programming Code Examples C > Bitwise Operators Code Examples Program to count trailing zeros in a binary number using while loop Program to count trailing zeros in a binary number using while loop Write a C program to input any number from user and count number of trailing zeros in the given number using bitwise operator. How to find total number of trailing zeros in any given number using bitwise operator in C programming. /* C program to count trailing zeros in a binary number using bitwise operator */ #include <stdio.h> int main() { int j, count=0; /* Input number from user */ printf("Enter any number: "); scanf("%d", &j); while(!(j & 1)) { count++; j >>= 1; } printf("Total number of trailing zeros = %d.", count); return 0; }