I am trying to write code for a binary search, but it is not showing any output. Please tell me my errors.
#include <iostream>
using namespace std;
int main(){
int a[]= {1, 3, 5 , 7, 32};
int n;
cin>>n;
int last=(sizeof(a)/sizeof(a[0]))-1;
int first=0;
while(first<=last){
int mid=(last-1)/2;
if(a[mid]==n){
cout<<"No. Found"<< endl;
}
if(n>a[mid])
{
first=mid+1;
}
else
{
last=mid-1;
}
}
cout<<"Not Found"<<endl;
return 0;
}