FUN WITH ROTATION

i have submitted the code
#include<stdio.h>
#include<stdlib.h>

void reverse(int arr[], int start, int end)
{
int temp;
if(start >= end)
return;
temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
reverse(arr, start+1, end-1);
}

void left_rotate(int str[],int n,int d){
int k,j,temp,i;
for(i=0;i<gcd(n,d);i++){
temp=str[i];
j=i;
while(1){
k=j+(d-1);
if(k>=n)
k=k-n;
if(k==i)
break;
str[j]=str[k];
j=k;
}
str[j]=temp;
}
}

void right_rotate(int str[],int n,int d){
reverse(str,0,n-1);
int k,j,temp,i;
for(i=0;i<gcd(d,n);i++){
temp=str[i];
j=i;
while(1){
k=j+(d);
if(k>=n)
k=k-n;
if(k==i)
break;
str[j]=str[k];
j=k;
}
str[j]=temp;
}
reverse(str,0,j);
reverse(str,j+1,n-1);
}

int gcd(int a,int b){
if(b==0)
return a;
else
return(gcd(b,a%b));
}

int main(){
int N,M,i,d;
int arr[100001];
scanf("%d %d",&N,&M);
getchar();
for(i=0;i<N;i++)
scanf("%d",&arr[i]);
getchar();
while(M–){
char q;
scanf("%c %d",&q,&d);
getchar();
switch(q){
case ‘R’: printf("%d\n",arr[d-1]);
break;
case ‘C’:right_rotate(arr,N,d);
/for(i=0;i<N;i++)
printf("%d “,arr[i]);
printf(”\n");
/
break;

	case 'A':left_rotate(arr,N,d);
			/*for(i=0;i<N;i++)
				printf("%d ",arr[i]);
			printf("\n");*/
		break;
	}
}
return 0;

}
i am getting the same output as given in sample output,but when i submitted ,getting wrong answer.
can anyone tell me ,what have gone wrong with my code.thanks in advance.

//