Create largest.py

have just added the largest number program hope it helps.
pull/837/head
Mihir Bhasin 2021-11-21 13:26:24 +05:30 committed by GitHub
parent 9ab84aab1e
commit 94f4f594dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -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)