2nd vedio of STL

#include
#include<bits/stdc++.h>
#include
using namespace std;

int main()
{
int arr[]={1,10,11,9,100};
int n= sizeof(arr)/sizeof(int);

int key;
cin>>key;
auto it=(arr,arr+n,key);
cout<<it<<endl;
int index= it - arr;
if(index==n)
cout<<key<<"not present";
else
cout<<"present at address"<<index;
return 0;

}
//GETTING ERROR WITH THE CODE AND THE ERROR IS:

invalid operands of types ‘int’ and ‘int [5]’ to binary ‘operator-’
int index= it - arr;
~^~~

//HELP ME TO FIX

Hi @hrit04,
in dis
auto it=(arr,arr+n,key);
u r not using any predefined function like lower_bound, upper_bound thats why its giving error when u r doing it-arr.
try using auto it=lower_bound(arr,arr+n,key);
ur code will work.
Hope dis helps.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.