Write a program that takes 20 elements of array from user at run time.
Find maximum element of array and swap it with last element of array.
Display before and after swapping array.
Answers
Answered by
0
Answer:
Program to find largest element in an array
Given an array, find the largest element in it.
Example:
Input : arr[] = {10, 20, 4} Output : 20 Input : arr[] = {20, 10, 20, 4, 100} Output : 100
Answered by
0
Answer:
In python it would look like
array = [10,200,60,40,20]
print("Array before sorting",array)
sorted_array = array.copy()
sorted_array.sort()
largest_value = sorted_array[-1]
array.append(largest_value)
print("Final array",array)
Explanation:
You can input all your values into the array. The sort method sorts the array from smallest to greatest. Take the last value from the sorted array and append it to the original array
Similar questions