Count number of bits to be flipped to convert a to b.
- prashant raj
- Mar 18, 2022
- 1 min read

#include <iostream>
using namespace std;
int main()
{
int a = 3 , b = 4;
int count = 0;
int x = a ^ b;
cout<<x<<endl;
while(x) {
if(x & 1)
{
count++;
}
x = x>>1;
}
cout<<count<<endl;
}
Commenti