#include<iostream.h>
#include<conio.h>
int a[10],i,x=1,y=9,l=9,m=9;
void begin(int b[])
{
for(i=0;a[i]!=0;i++)
b[i]=b[i+1];
b[l]=0;
l--;
}
void end(int b[])
{
b[l]=0;
l--;
}
void position(int b[])
{
int p;
cout<<"\nEnter the position where element has to be deleted: ";
cin>>p;
if(b[p]!=0)
{
for(i=p-1;a[i]!=0;i++)
b[i]=b[i+1];
b[m]=0;
m--;
}
else
cout<<"\nElement has been deleted."<<endl;
}
void display(int b[])
{
cout<<"\nArray: ";
for(i=0;i<10;i++)
cout<<b[i]<<" ";
cout<<endl;
}
void main()
{
clrscr();
cout<<"Enter elements of array: "<<endl;
for(i=0;i<10;i++)
{
cout<<"Enter element no."<<i+1<<": ";
cin>>a[i];
}
clrscr();
int ch;
do
{
cout<<"1.Delete an element at the begining."<<endl;
cout<<"2.Delete an element at the end."<<endl;
cout<<"3.Delete an element at the desired position."<<endl;
cout<<"4.Display array."<<endl;
cout<<"5.Exit"<<endl;
cout<<"Enter your choice: ";
cin>>ch;
switch(ch)
{
case 1: {
begin(a);
break;
}
case 2: {
end(a);
break;
}
case 3: {
position(a);
break;
}
case 4: {
display(a);
break;
}
case 5: {
break;
}
default: {
cout<<"\nWrong choice entered."<<endl;
break;
}
}
cout<<endl;
}
while(ch!=5);
}