1#include<stdio.h>
2
3void main()
4{
5 int i,n,a[100],temp;
6
7 printf("Enter the number of elements:\n") ;
8 scanf("%d",&n);
9
10 printf("Enter the elements\n");
11 for(i=0;i<n;i++)
12 {
13 scanf("%d",&a[i]);
14 }
15
16 printf("Original array\n");
17 for(i=0;i<n;i++)
18 {
19 printf("%d ",a[i]);
20 }
21
22 /* shifting array elements */
23 temp=a[n-1];
24 for(i=n-1;i>0;i--)
25 {
26 a[i]=a[i-1];
27 }
28 a[0]=temp;
29
30 printf("\nNew array after rotating by one postion in the right direction\n");
31 for(i=0;i<n;i++)
32 {
33 printf("%d ",a[i]);
34 }
35}
36