From 94f4f594dd9e20a8f6f45743a4e406c8b7bc3b14 Mon Sep 17 00:00:00 2001 From: Mihir Bhasin <57122515+Mihir-Bhasin@users.noreply.github.com> Date: Sun, 21 Nov 2021 13:26:24 +0530 Subject: [PATCH] Create largest.py have just added the largest number program hope it helps. --- Day01-15/code/Day05/largest.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Day01-15/code/Day05/largest.py 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)