Sure! Here is an example program in Python that finds the maximum element in an array:
def find_max_element(arr): max_element = arr[0] for i in range(1, len(arr)): if arr[i] > max_element: max_element = arr[i] return max_element # Test the function array = [3, 7, 2, 10, 5] max_element = find_max_element(array) print("The maximum element in the array is:", max_element)
This program defines a function called find_max_element that takes an array as input and returns the maximum element in the array. It then tests the function by creating an array [3, 7, 2, 10, 5] and prints out the maximum element in the array.
Sure! Here is an example program in Python that finds the maximum element in an array:
def find_max_element(arr):max_element = arr[0]
for i in range(1, len(arr)):
if arr[i] > max_element:
max_element = arr[i]
return max_element
# Test the function
array = [3, 7, 2, 10, 5]
max_element = find_max_element(array)
print("The maximum element in the array is:", max_element)
This program defines a function called find_max_element that takes an array as input and returns the maximum element in the array. It then tests the function by creating an array [3, 7, 2, 10, 5] and prints out the maximum element in the array.