Program to cyclically rotate an array by one
Program to cyclically rotate an array by one
Given an array, cyclically rotate the array clockwise by one. Examples: Input: arr[] = {1, 2, 3, 4, 5} Output: arr[] = {5, 1, 2, 3, 4} Following are steps for Array Rotation. Store last element in a variable say x. Shift all elements one position ahead. Replace first element of array with x. #include <stdio.h> void rotate(int arr[], int n) { int x = arr[n-1], i; for (i = n-1; i > 0;…
View On WordPress




















