int n;
cin>>n;
int i=1,m=1;
while(n&i==0)
{
i=i<<1;
m++;
}
//now flip mth set bit from right;
int ans=n^(1<<(m-1));
cout<<ans<<endl;
What is the mistake in the above code for unsetting the rightmost bit of an integer?