i have question
suppose there is gven two number we should find how many common 1 bit is in these number
for example 5 and 6
5//101
6//110 there is 1 common bit at the same position
i have following code
#include <iostream>
using namespace std;
int main(){
int a,b;
int count=0;
cin>>a>>b;
while ((a & b)!=0){
count++;
a>>=1;
b>>=1;
}
cout<<count<<endl;
return 0;
}
and when i entered 335 and 123 it returned 7 but i think it is not correct