1. PROGRAM 17
AIM: To create a menu driven program to insert & delete an element in a sorted array
SOLUTION:
#include<iostream.h>
#include<conio.h>
void initialize(int a[],int s);
void display(int a[],int s);
void insert(int a[],int &m);
void del(int a[],int &siz);
void main()
{
int ch,arr[70],size=0;
char p;
do
{
clrscr();
cout<<"||PROGRAM TO INSERT AND DELETE AN ELEMENT IN A SORTED 1D
ARRAY||";
cout<<"nn MENU:";
cout<<"n1.INITIALISE ARRAYn2.DISPLAY ARRAYn3.INSERT AN ELEMENT";
cout<<"n4.DELETE AN ELEMENT";
cout<<"nnEnter your choice ";
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"Enter the size of array ";
cin>>size;
cout<<"nn##Initialise in ascending order##n";
initialize(arr,size);
}
break;
case 2:
display(arr,size);
break;
case 3:
insert(arr,size);
break;
case 4:
del(arr,size);
break;
}
cout<<"nTo go back to menu press y: