n=int(input ("Enter the number of elements in the array: "))
i =0
l=[]
for i in range(n):
    num=int(input())
    l.append(num)
print("Array is: ", l)
val= int(input("Enter the number to be searched: "))
beg=0
end=n-1
found=0
while(beg<end):
    mid=int((beg+end)/2)
    if(l[mid]==val):
        print("Number found at position:", mid) 
        found=1
        break
    elif(l[mid]>val):
        end=mid-1
    elif(l[mid]<val):
        beg=mid+1
if(found==0):
    print("Number not found")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: