What is wrong with this code

#include
using namespace std;
int fun(long long int a[1000000],int n,long long int key)
{
int l=0;
int h=n-1;
while(l<=h)
{ int mid=(l+h)/2;
if(a[mid]<key)
{
l++;
}
else if(a[mid]>key)
{
h–;
}
else{
return mid;
}
}
return 0;
}
int main() {
int n;
cin>>n;
long long int arr[100000];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
long long int key;
cin>>key;
cout<<fun(arr,n,key);
return 0;
}

@Kunalgoyal lot of small errors.
l=mid+1 in first mid cond, e=mid-1 instead of e-- , return -1 not 0 in case not found.

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.