CTS Interview Question Question description Issac is a Language teacher at a high school in Madurai. Sabari is a student, he is studying programming while during Language class. Issac tells Sabari to leave the other subject and learn Tamil. Sabari asked permission for 10 minutes, Finally, Sabri got permission to solve the program. The computer teacher has given homework on the topic of Arrays and where he need to do Array Rotation as per the input of question. . But Sabari is not good at C Programming. Can you help him to solve the programming problem? Constraints 0
C Program


#include<stdio.h>

int rotLeft(int arr[],int n,int d)

{

int i,j,temp;

d=d%n;

for(i=0;i<d;i++)

{

temp=arr[0];

for(j=0;j<n-1;j++)

arr[j]=arr[j+1];

arr[n-1]=temp;

}

return 0;

}

int rotRight(int arr[],int n,int d)

{

int i,j,temp;

d=d%n;

for(i=0;i<d;i++)

{

temp=arr[n-1];

for(j=n-1;j>0;j--)

arr[j]=arr[j-1];

arr[0]=temp;

}

return 0;

}

int main()

{

int n,d,i;

scanf("%d",&n);

int arr[100];

for(i=0;i<n;i++)

scanf("%d",&arr[i]);

scanf("%d",&d);

char c;

scanf(" %c",&c);

if(c=='L')

rotLeft(arr,n,d);

else

rotRight(arr,n,d);

for(i=0;i<n;i++)

printf("%d ",arr[i]);

return 0;

}