Sure! Here is the P6PR3 program to search for the maximum element in a one-dimensional array:
import random
# Generate a random array of size n
n = 10 # Change the size of the array here
arr = [random.randint(1, 100) for _ in range(n)]
# Print the generated array
print("Array: ", arr)
# Find the maximum element and its index
max_value = max(arr)
max_index = arr.index(max_value)
# Print the maximum element and its index
print("Maximum value: ", max_value)
print("Index: ", max_index)
This program generates a random one-dimensional array of size n (set as 10), finds the maximum element in the array using the max() function, and then retrieves its index using the index() method. Finally, it prints the maximum element and its index.
You can change the size of the array by modifying the n variable.
