Computer Science, asked by jeevan7194gmailcom, 11 months ago

Write a program to rotate array elements by a given number of rotation in the given range
Sample Input:
Size - 6
Arr[] - {2 4 6 8 10 12}
Number of rotation -1
Range - 24
Sample Output:
2 4 10 6 8 12​

Answers

Answered by RudraPratapSingh456
6

Answer:

vzhsdhieej shjwwg the condition is that it was great meeting

Answered by lovingheart
2

A program to rotate array elements:

void Rotatearray(int arr[], int d, int n)  

{  

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

       {

  int temp = arr[0], i;  

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

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

 

     arr[j] = temp;  

 }

}  

In the above function, it rotates the array of size n by‘d’. It runs a nested loop, the first loop runs till the value of  the variable ‘d’ is attained and the inner loop runs to swap the value of array. Here the ‘n’ represents the size and the variable‘d’ represents how may values to be shifted per rotation.

Similar questions