diff --git a/Day01-15/code/Day05/largest.py b/Day01-15/code/Day05/largest.py new file mode 100644 index 0000000..30eadde --- /dev/null +++ b/Day01-15/code/Day05/largest.py @@ -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)