C program to cyclically permute the elements of an array


Levels of difficulty: / perform operation:

This program we, cyclically permute the array elements i.e. arr[0] becomes arr[1], arr[1] becomes arr[2]…so ..on.


C Program

#include <stdio.h>
void main () {
	int i,n,number[30];
	printf("Enter the value of the n = ");
	scanf ("%d", &n);
	printf ("Enter the numbers\n");
	for (i=0; i<n; ++i) {
		scanf ("%d", &number[i]);
	}
	number[n] = number[0];
	for (i=0; i<n; ++i) {
		number[i] = number[i+1];
	}
	printf ("Cyclically permted numbers are given below \n");
	for (i=0; i<n; ++i)
	 printf ("%d\n", number[i]);
}