hello I want to implement binary search.The code seems correct to me,but I think a small mistake I cant see makes it not work,here is the code(and thank you in advance):
#include<stdio.h>
#include<conio.h>
int low=0,high,v[10],i,x;
int binarysearch(int v,int x,int low,int high);
int main()
{
printf("val cautata x=");
scanf("%d",&x);
printf("\n");
printf("lungimea vectorului este=");
scanf("%d",&high);
for(i=0;i<=high-1;i++)
{
scanf("%d",v[i]);
}
printf("%d",binarysearch(v,x,low,high));
getch();
}
int binarysearch(int v,int x,int low,int high)
{ int mid;
if(high<low) return -1;
mid=(low+high)/2;
if (x>v[mid]) return binarysearch(v,x,mid+1,high);
else if (x<v[mid]) return binarysearch(v,x,low,mid-1);