i have to make a program that does quick searching and well it works fine untill someone enters a number not in the list

here is the function

thx for any helpCode:int q_search(int ray[], int find, int left, int right) { int Pivot = (left + right) / 2; if(ray[Pivot] > find && Pivot-left != 1) Pivot = q_search(ray, find, left, Pivot); else if(ray[Pivot] < find && right-Pivot != 1) Pivot = q_search(ray, find, Pivot, right); if(ray[Pivot]==find) return Pivot; if(right-Pivot==1 || Pivot-left == 1 && ray[Pivot] != find) return -1; }