Thursday, 11 May 2017
Binary Search in c++ Explanation [22]
#include<constream.h>
#include<iomanip.h>
void main(){
clrscr();
// ARRAYS Binary Searching
int numbers[8]={22,33,44,55,66,77,88,99};
int start = 0;
int end = 7;
int mid;
int num = 123;
while(start <= end)
{
mid = (start+end)/2;
if(numbers[mid] ==num)
cout<<"Found";
if(num > numbers[mid])
start = mid+1;
else
end = mid-1;
}
getch();
}
Labels:
C++,
c++ full course,
c++ projects,
c++ videos,
cplus,
hindi,
in Urdu
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment