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.
/* 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. */#include<stdio.h>unsignedinvert(unsignedx,intp,intn);intmain(){unsignedx=0xABCD;printf("x = %d\n",x);x=invert(x,6,4);printf("modified x = %d\n",x);return0;}unsignedinvert(unsignedx,intp,intn){unsignedtemp=0;temp=((~(~0U<<n))<<(p+1-n));return((x)^(temp));}