C Program For Shifting Array elements to left side

#include<stdio.h>
#include<conio.h>
void main()
{
int i,a[10],n,ele;
clrscr();
printf("enter the value of n: ");
scanf("%d",&n);
printf("\nenter the values");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
ele=a[0];
for(i=0;i<n;i++)
{
 if(i==n-1)
  a[i]=ele;
 else
  a[i]=a[i+1];
}
printf("\nelements are:\n");
for(i=0;i<n;i++)
printf("%d\n",a[i]);
getch();
}


Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment