Code:
print("enter size of an array")
s=int(input())
i=0
b=[]
print("enter array elements")
while i<s:
b.append(int(input()))
i=i+1
print(b)
def getSecondHighest(b):
hi=mid=lo=0
for i in range(0,len(b)):
x=b[i]
if(x>hi):
lo=mid
mid=hi
hi=x
elif(x<hi and x>mid):
lo=mid
mid=x
elif(x<lo):
lo=x
return mid
print("second largest element in given array",getSecondHighest(b))
O/p:-
0 Comments