Finding a number using Binary search in a function

This program searches for a number entered by the user using binary search method in a function.

[code=’cpp’]//Binary Search
void bin_search(int x,int n,int a[]);
void main()
int n,a[30],x;
cout<<"Enter the number of elements : "; cin>>n;
for(int i=0;i>a[i];

cout<<"Enter the no. : "; cin>>x;


void bin_search(int x,int n,int a[])
int f=0,l=n-1,m;
while(f<=l) { m=(f+l)/2; if(a[m]==x) { break; } else if(x