Deleting Element In An Array


#include<stdio.h>
#include<conio.h>
void main()
{
int num[20],j,p,n,s;
clrscr();
printf(“enter the number of elements\n”);
scanf(%d”,&n);
printf(“enter the elements of array\n”);
for(j=0;j<n;j++)
scanf(%d”,&num[j]);
printf(“enter the position to delete\n”);
scanf(%d”,&p);
p--;
for(j=p;j<n;j++)
num[j]=num[j+1];
for(j=0;j<n-1;j++)
printf(%d”,num[j]);
getch();
}

Output:
enter the number of elements
3
enter elements
1
2
3
enter the position to delete 
2
1  3  


Labels