Driver code
public static void Main ( ) { GFG ob = new GFG ( ) ; int [ ] arr = { 3 , 2 , 10 , 4 , 40 } ; int n = arr . Length ; int x = 4 ; int result = ob . binarySearch ( arr , 0 , n - 1 , x ) ; if ( result == - 1 ) Console . Write ( " Element ▁ is ▁ not ▁ present ▁ in ▁ array " ) ; else Console . Write ( " Element ▁ is ▁ present ▁ at ▁ index ▁ " + result ) ; } }