Exercise 2-8. Write a function rightrot(x,n) that returns the value of the integer x rotated to the right by n positions.
/* Exercise 2-8. Write a function rightrot(x,n) that returns the value of the integer x rotated to the right by n positions. */#include<stdio.h>unsignedrightrot(unsignedx,intn);intunsignedlength(void);intmain(){unsignedx=99;printf("x = %d\n",x);x=rightrot(x,5);printf("modified x = %i\n",x);return0;}unsignedrightrot(unsignedx,intn){intlength=unsignedlength();printf("bit length of x = %d\n",length);return((x>>n)|(((x)&(~(~0U<<n)))<<(length-n)));}/* bitlength: count no of bits in x */intunsignedlength(void){intb;unsignedy;y=(~0);/* sets every bit of y to 1*/for(b=0;y!=0;y>>=1)b++;returnb;}