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
Python3
# Python3 program to find maximum # in arr[] of size n # 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 # Driver Code arr = [10, 324, 45, 90, 9808] n = len(arr) Ans = largest(arr,n) print ("Largest in given array is",Ans) # This code is contributed by Smitha Dinesh Semwal |
chevron_right
filter_none
Please refer complete article on Program to find largest element in an array for more details!
Recommended Posts:
- Python Program to Print Largest Even and Largest Odd Number in a List
- Python program to find N largest elements from a list
- Python Program for Find largest prime factor of a number
- Python program to find largest number in a list
- Python program to find second largest number in a list
- Python Program for Largest K digit number divisible by X
- Python Program for Largest Sum Contiguous Subarray
- Python program to extract N largest dictionaries keys
- Python Program for Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Python Program for Program to find area of a circle
- Python | Slicing list from Kth element to last element
- Python Program for Find remainder of array multiplication divided by n
- Python Program to find sum of array
- Second largest value in a Python Dictionary
- Python | Largest number possible from list of given numbers
- Python | N largest values in dictionary
- Python | Indices of N largest elements in list
- Python program to insert an element into sorted list
- Python program to search for the minimum element occurring consecutively n times in a matrix
- Python program to covert tuple into list by adding the given string after every element

