/* ThisProgramDemonstrate Binary SearchAlgorithm(For arrays arranged in ascending order. */# Include <iostream> using namespace STD;/* function: returns the following values: the subscript of the keyword in the array. If-1 is returned, a []: The number of elements in the array Len: keyword */INT binsearch (int A [], int Len, int key) {int I = Len/2; int II = 0; If (LEN <1) return-1; if (Key> A [I]) & (LEN-I> 0) {II = binsearch (a + I + 1, len-I-1, key); // search for if (II! =-1) return II + I + 1; // Add the length of the first half of the array, elsereturn-1;} else if (Key <A [I] & I> 0) // search for return binsearch (A, I, key); else if (Key = A [I]) return I in the first half of the array; // returns the subscript elsereturn-1 of the keyword in the array; // The keyword} int main () {int A [] = {2, 4, 5, 20, 24, 35, 66, 78, 98}; int Len = sizeof (a)/sizeof (INT); int I, key =-1; while (1) {CIN> key; I = binsearch (A, Len, key); printf ("% d \ n", I); If (Key> 100) break ;} return 0 ;}