C Programming Code Examples C > Bitwise Operators Code Examples Count the Number of Bits needed to be Flipped to Integer X to Generate Integer Y Count the Number of Bits needed to be Flipped to Integer X to Generate Integer Y #include <stdio.h> #include <stdlib.h> #define num_bits_int (sizeof(int)*8) void main() { int n, m, x, count = 0, a, b; printf("Enter the number\n"); scanf("%d", &n); printf("Enter another number\n"); scanf("%d", &m); for (x = num_bits_int-1;x >= 0;x--) { a = (n >> x)& 1; b = (m >> x)& 1; if (a != b) count++; } printf("flip count = %d\n", count); }