I have recharge my balance from my account and changed the balance amount from my account and changed the balance amount from my account and changed the balance amount from my account and changed the balance amount from
I have recharge my balance from my account and changed the balance amount from my account and changed the balance amount from my account and changed the balance amount from my account and changed the balance amount from
I have recharge my balance from my account and changed the balance amount from my account and changed the balance amount from my account and changed the balance amount from my account and changed the balance amount from
{ int beg,last,mid; beg=0; last=size-1; while(beg<=last) { mid=(beg+last)/2; if(element==AR[mid]) return mid; else if(element>AR[mid]) beg=mid+1; else last=mid-1; } return -1; } void main( ) { int AR[50],element,N,index,ch; char opt='y'; cout<<"\nEnter desired array size(max.50)::"; cin>>N; cout<<"\nEnter array element(must be sorted in asce order)"; for(int i=0;i<N;i++) cin>>AR[i]; do { cout<<"\nEnter element to be searched for::"; cin>>element; cout<<"\n MENU"; cout<<"\n 1. LINEAR SEARCH"; cout<<"\n 2. BINARY SEARCH"; cout<<"\n 3. EXIT"; cout<<"\n Enter ur choice::"; cin>>ch; switch(ch) { case 1: index=Lsearch(AR,N,element); break; case 2:index=Bsearch(AR,N,element); break; case 3:exit(0); } if(index==-1) cout<<"\nsorry!! given element could not be found,\n"; else cout<<"\nElement found at index : " << index<< "position:" <<index+1<<endl;