My binary search showing error

#include
using namespace std;

int binary_search(int a[],int n)
{

int s=0;
int e=n-1;
int mid;
while(s<=e)
{
mid=(s+e)/2;
if(a[mid]==key)
{
return mid;
}
else if(a[mid]>key)
{
e=mid-1;
}
else(a[mid]<key)
{
s=mid+1;
}
}
return -1;
}
int main(){
int n,key;
cout<<“enter n=”;
cin>>n;
for(i=0;i<n;i++)
{
cin<<a[i]<<",";
}
cout<<“element to be searched=”;
cin>>key;
cout<<binary_search(a,n,key)<<endl;
return 0;
}

Hey @lovepreet_singh

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.