You don't need to know the position of the LSB. And this is great because due to endianness it could be at multiple places!
Let us find some help: How do you set, clear, and toggle a single bit?:
Checking a bit
You didn't ask for this, but I might as well add it.
To check a bit, shift the number n to the right, then bitwise AND it:
bit = (number >> n) & 1U;
Changing the nth bit to x
Setting the nth bit to either 1 or 0 can be achieved with the following on a 2's complement C++ implementation:
number ^= (-x ^ number) & (1UL << n);
And go for it!
int swap_nth_and_lsb(int x, int n)
{
// let to the reader: check the validity of n
// read LSB and nth bit
int const lsb_value = x& 1U;
int const nth_value = (x>> n) & 1U;
// swap
x ^= (-lsb_value) & (1UL << n);
x ^= /* let to the reader: set the lsb to nth_value */
return x;
}
In the comment, OP said "I have to write one line of code for getting result". Well, if the one-line condition holds, you can start from the above solution and turn it into a one-liner step by step.