Write a function that findsreturns the index of the maximum element in the array
ID: 3616920 • Letter: W
Question
Write a function that findsreturns the index of the maximum element in the array.
int MaxIndex(int arr[], intsize)
Use the above function toimplement selectionSort, i.e.,
void selectionSort(intarr[], int size)
This is an example of howselection sort works
Take the array and find themaximum in thearray: arr = 3 4 5 91 (maximum = 9)
Place the maximum value atthe lastindex arr = 3 4 5 19 (9 is at correct place)
find the maximum in thearray of size 4 arr = 3 4 5 19 (maximum = 5)
Place the maximum at lastindex-1 arr = 3 4 1 59 ( 5 and 9 are at correct place)
find maximum in the arrayof size3 arr = 3 4 1 59 (maximum = 4)
place the maximum at lastindex-2 arr = 3 1 4 59 (4,5,9 are at correct place)
Keep repeating the abovesteps till array is sorted
Also write the mainfunction to test your program.