Saturday, 28 July 2018

Find Largest Element of an Array using Function in Python

# Find Largest Element of an Array using Function

# python function to find maximum
# in arr[] of size n
def largest(arr,n):

# Initialize maximum element
max = arr[0]

# Traverse array elements from second
# and compare every element with
# current max
for i in range(1, n):
if arr[i] > max:
max = arr[i]
return max
# Drive Code
arr =[i for i in  range(100)]
   
n = input(" Enter total number of elements(1 to 100):")
n=int(n);

for i in range(n):
    arr[i]=  input(" Enter Number for index {0} ".format(int(i)));


Ans = largest(arr,n)
print ("Largest in given array is",Ans)


   


1 comment:

  1. Sir What is the scope of Python
    Should i learn it or not at this time

    ReplyDelete

Upload valid file in C#

    protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile)     {         try         {             Dictionary<string, byte[]>...