Left Shift Elements

Given an array from the user the task is to left shift array all elements by one place.

Example:

Consider an array of size 5.

26497

Left shifted array.

64972

Note: Here the first element is brought to last position of the array.

C
#include <stdio.h>
int main()
{
    int n=0,temp=0;
    printf("Enter the size of array: ");
    scanf("%d",&n);
    int ar[n];
    printf("Enter the array elements:-\n");
    for(int i=0;i<n;i++)
    {
        scanf("%d",&ar[i]);
    }
    temp=ar[0];
    for(int i=0;i<n-1;i++)
    {
       ar[i]=ar[i+1]; 
    }
    ar[n-1]=temp;
    printf("Left shifted array: ");
    for (int i=0;i<n;i++)
    {
        printf("%d ",ar[i]);
    }
    return 0;
}
C