Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Name: DIPAK YADAV Date:

01/04/2019
USN: 1NH18CS059

#include <stdio.h>
unsigned int rightrot(unsigned int a,unsigned int b){
for(int i=0;i<b;i++){
if(a%2==0){
a=a>>1;
}else{
a=a>>1;
a+=32768;
}
}

return a;
}

int main(){

unsigned int x,n,res;

printf("Enter the number you want to rotate:");


scanf("%u",&x);
printf("\nEnter he number of times you want to rotate:");
scanf("%u",&n);

res = rightrot(x,n);

printf("\nRight rotate(%d,%d)=%d",x,n,res);
return 0;
}

You might also like