Swap bits in a given number

this is a gfg problem in intermediate section , even after looking at solution i am not able to understand it kindly give ciode or explain their answer

@royprincejmp can you please give me link so that we can discuss but without that link it’s not possible.

@jaiskid the link is https://www.geeksforgeeks.org/swap-bits-in-a-given-number/