/*array insertion,deletion,print,traverse*/
#include
#include
#include
int arr[5];
// insertion function
void a_insert(int num, int pos)
{
for(int i=4; i>=pos;i--)
arr[i]=arr[i-1];
arr[i]=num;
}
// deletion function
void a_delete(int pos)
{
for(int i=pos; i<=4;i++) arr[i-1]=arr[i]; arr[i-1]=0; } void main(void) { int ch,num,pos; while(1) { clrscr(); cout<<"\nMenue Program of Array\n"; cout<<"\n1. Insertion in Array"; cout<<"\n2. Deleteion in Array"; cout<<"\n3. Print the Array"; cout<<"\n4. Traevers the Array"; cout<<"\n5. Quit\n"; cin>>ch;
switch(ch)
{
case 1:
cout<<"enter element:"; cin>>num;
cout<<"enter position:"; cin>>pos;
a_insert(num,pos);
break;
case 2:
cout<<"enter pos.:"; cin>>pos;
a_delete(pos);
break;
case 3:
cout<<"\nArray:";
for(int i=0;i<5 br="" i=""> cout<
getch();
break;
case 4:
for(i=0;i<5 br="" i=""> {
cout<
cout<
}
getch();
break;
case 5:
exit(0);
break;
default:
cout<<"Invalid Selection";
}
}
} 5> 5>
#include
#include
#include
int arr[5];
// insertion function
void a_insert(int num, int pos)
{
for(int i=4; i>=pos;i--)
arr[i]=arr[i-1];
arr[i]=num;
}
// deletion function
void a_delete(int pos)
{
for(int i=pos; i<=4;i++) arr[i-1]=arr[i]; arr[i-1]=0; } void main(void) { int ch,num,pos; while(1) { clrscr(); cout<<"\nMenue Program of Array\n"; cout<<"\n1. Insertion in Array"; cout<<"\n2. Deleteion in Array"; cout<<"\n3. Print the Array"; cout<<"\n4. Traevers the Array"; cout<<"\n5. Quit\n"; cin>>ch;
switch(ch)
{
case 1:
cout<<"enter element:"; cin>>num;
cout<<"enter position:"; cin>>pos;
a_insert(num,pos);
break;
case 2:
cout<<"enter pos.:"; cin>>pos;
a_delete(pos);
break;
case 3:
cout<<"\nArray:";
for(int i=0;i<5 br="" i=""> cout<
break;
case 4:
for(i=0;i<5 br="" i=""> {
cout<
getch();
break;
case 5:
exit(0);
break;
default:
cout<<"Invalid Selection";
}
}
}