Advertisement
hamzajaved

Largest Element in Array

Dec 19th, 2021
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. def largest(arr,n):
  2.     max = arr[0]
  3.     for i in range(1, n):
  4.         if arr[i] > max:
  5.             max = arr[i]
  6.     return max
  7.  
  8. # Driver Code
  9. arr = [10, 324, 45, 90, 9808]
  10. n = len(arr)
  11. Ans = largest(arr,n)
  12. print ("Largest in given array is",Ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement