Create largest.py
have just added the largest number program hope it helps.pull/837/head
parent
9ab84aab1e
commit
94f4f594dd
|
@ -0,0 +1,19 @@
|
|||
``` Given an array, find the largest element in it.
|
||||
|
||||
Input : arr[] = {10, 20, 4}
|
||||
Output : 20
|
||||
|
||||
Input : arr[] = {20, 10, 20, 4, 100}
|
||||
Output : 100 ```
|
||||
|
||||
def largest(arr,n):
|
||||
max = arr[0]
|
||||
for i in range(1, n):
|
||||
if arr[i] > max:
|
||||
max = arr[i]
|
||||
return max
|
||||
|
||||
arr = [10, 324, 45, 90, 9808]
|
||||
n = len(arr)
|
||||
Ans = largest(arr,n)
|
||||
print ("Largest in given array is",Ans)
|
Loading…
Reference in New Issue