In the above program, we declared an array arr[] = {5, 10, 15, 20, 25, 30, 35, 40); and then we specified number '25' to which search from the sorted array using the binary search method. Therefore, we create a user-defined function bin_search() that searches the given number and returns the statement "Element is found at position 5". If the number is not defined in the array, the bin_search() function shows " Element is not found in the array."
In the above program, we declared an array arr[] = {5, 10, 15, 20, 25, 30, 35, 40); and then we specified number '25' to which search from the sorted array using the binary search method. Therefore, we create a user-defined function bin_search() that searches the given number and returns the statement "Element is found at position 5". If the number is not defined in the array, the bin_search() function shows " Element is not found in the array."