Menu Driven Program of Insertion, Deletion and Binary Search
This program implements a menu driven program for insertion, deletion and binary search operations on an array. It takes input from the user for the length of the array and elements. It displays a menu for choice of operation - insertion at a position, deletion of an element, or searching for an element. Based on the choice, it performs the respective operation on the array and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
55 views4 pages
Menu Driven Program of Insertion, Deletion and Binary Search
This program implements a menu driven program for insertion, deletion and binary search operations on an array. It takes input from the user for the length of the array and elements. It displays a menu for choice of operation - insertion at a position, deletion of an element, or searching for an element. Based on the choice, it performs the respective operation on the array and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4
Menu Driven program of
Insertion,Deletion and Binary Search
#include<iostream.h> #include<conio.h> void main( ! clrscr(" int #,p,a$%&',n,d,t(&,ch" char l" do ! cout<<)*nter the length of array)" cin>>n" cout<<)*nter the elements)" for(int i(&"i<n"i++ cin>>a$i'" cout<<)Menu,n-.Insertion,n%.Deletion,n..Binary Search)<<endl" cout<<)*nter your choice )" cin>>ch" s/itch(ch ! case -0 cout<<)*nter the position )"
cin>>p" cout<<)*nter the element to 1e inserted )" cin>>#" if(p<(n+- ! for(i(n"i>(p"i22 a$i'(a$i2-'" a$p2-'(#" n++" cout<<)*lements after insertion are)<<endl" for(i(&"i<n"i++ cout<<a$i'<<endl" 3 else cout<<)4rong 5osition)"
1rea6"
case %0 cout<<)*nter the element to 1e deleted )" cin>>d" for(i(&"i<n"i++ ! if(a$i'((d ! for(int 6(i"6<(n2-"6++ a$6'(a$6+-'" t(-" 1rea6" 3 3 if(t((- ! n22" cout<<)7rray after deletion is)<<endl" for(i(&"i<n"i++ cout<<a$i'<<endl" 3 else cout<<)4rong *lement)" 1rea6" case .0 int l,h,m,s" l(&" h(n2-" cout<<)*nter the element to 1e searched )" cin>>s" /hile(l<(h ! m((l+h8%" if(a$m'((s ! cout<<)*lement found at )<<m+-<<) 5osition)" t(-" 1rea6" 3 else if(s>a$m' l(m+-" else h(m2-" 3 if(t((& cout<<)*lement not found)" 1rea6" default0 cout<<)5lease *nter the given choices)<<endl" 3 cout<<)Do you /ish to continue(y8n )" cin>>l" 3/hile(l((9y9::l((9;9" getch(" 3