Deletion in array:
# include<stdio.h>
int main()
{
int a[]={2,4,5,6,89,67,56};
int l,i,p;
int ch;
l=sizeof (a)/sizeof(a[0]);
x: if(l<=0)
printf("array is empty");
printf("\n\n enter 1 to delete from first position\n enter 2 to delete from any posittion\n enter 3 to delete
from last position \n enter 4 to exit\n enter your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:{
for(i=0;i<l;i++)
{
a[i]=a[i+1];
}
l-=1;
for(i=0;i<l;i++)
{
printf(" %d",a[i]);
}
goto x;
break;
}
case 2:{
y: printf("\n enter index : ");
scanf("%d",&p);
if(p<l)
{
for(i=p;i<l;i++)
{
a[i]=a[i+1];
}
l-=1;
for(i=0;i<l;i++)
{
printf(" %d",a[i]);
}
goto x;
}
else
{
printf("\n invalid index! the length of the array is %d",l);
goto y;
break;
}
case 3:{
a[l-1]=a[l];
l-=1;
for(i=0;i<l;i++)
{
printf(" %d",a[i]);
}
goto x;
break;
}
case 4:{
break;
}
default:{
printf("\nenter valid choice\n");
goto x;
break;
}
}
return 0;
}