Https://www.geeksforgeeks.org/swap-bits-in-a-given-number/

what is 1U-1 in the code please explain
if there is another approach give that/…

Hey @guptanikhil898 in which code you are getting issue to understand? First one or second?

i have doubt int he first method what is 1U-1 here

1U is an unsigned value with the single bit 0 set, and all the other bits cleared. The << operator means “shift to the left”. 1U << 0 means create a value with bit 0 set; 1U << 1 means create a value with bit 1 set

Refer this if you want to learn more about it http://www.cplusplus.com/forum/beginner/992/

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.