binary_search in stl code example
Example: how to do binary search in c++ using STL
// BY shivam kumar KIIT
#include<bits/stdc++.h>
usind namespace std;
int main()
{
int arr[]={10,2,34,2,5,4,1};
sort(arr,arr+7);//sort array in ascending order before using binary search
binary_search(arr,arr+7,10);//return 1 as element is found
binary_search(arr,arr+7,3);//return 0 as element is not found
return 0;
}