Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int a[100],i,n,temp;
- printf("Enter the array's limit: ");
- scanf("%d",&n);
- printf("Now enter %d elements to fill the array.\n",n);
- for(i=0; i<n; i++)
- scanf("%d",&a[i]);
- temp = a[n-1];
- for(i=n-2;i>=0;i--)
- a[i+1] = a[i];
- a[0] = temp;
- printf("The new array after right shift is:-\n");
- for(i=0; i<n;i++)
- printf("%d",a[i]);
- return 0;
- }
- //Output
- //Enter the array's limit: 5
- //Now enter 5 elements to fill the array.
- //1
- //2
- //3
- //4
- //5
- //The new array after right shift is:-
- //51234
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement