0

okay i understand all bitwise operators but in the chapter of k&r at bitwise operators i m really lost at there question i have no idea how to do them

Exercise 2-6. Write a function setbits(x,p,n,y) that returns x with the n bits that begin at

position p set to the rightmost n bits of y, leaving the other bits unchanged.

Exercise 2-7. Write a function invert(x,p,n) that returns x with the n bits that begin at

position p inverted (i.e., 1 changed into 0 and vice versa), leaving the others unchanged.

3rd one was easy so i did it but i have no idea how to do those could anyone give me any idea how to code them ?