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):")

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


Getting Available Server Disk Space (Total Size / Free Space) SQL Query

SELECT distinct(volume_mount_point), total_bytes/1048576 as Size_in_MB, total_bytes/1048576/1024 as Size_in_GB, available_bytes/1048576 ...