question:
answer:
hello @aarijrab
first we are checking whether kth bit of n is 1 or not.
if it is 1 then we are setting it to 0.
and this is the logic we are using to turn it 0.
To turn off the particular bit in given number we use bitwise ‘<<‘, ‘&’ and ‘~’ operators. Using expression “~(1 << (k – 1))“, we get a number which has all bits set, except the k’th bit. If we do bitwise ‘&’ of this expression with n, we get a number which has all bits same as n except the k’th bit which is 0.
but my code is not woeking ,…could you please correct it and mention me errors in // comments
i think ur code is right.
they have not cleared from what direction they are counting k .
their explanation is also creating confusion->

here 3rd bit from left of 13 is set but then also they have returned 13
same is the case with second case.
my code is not executing…please correct mt code
u r trying to execute it in c .
change language setting to c++ and then it will work