(Index of second largest element) Write a function that returns the index of the second largest element in an array of integers
Use the following header: int index_Of_Second_Largest_Element(int[] array) A sample run: 4 3 6 7 9 8 10 The index of the second largest element is 4 There is something wrong with my code here š #include <iostream> using namespace std; int index_Of_Second_Largest_Element(int array[] ); int n, num[10], largest, second, array; int main(){ cout<<"Enter number of elements: "; cin>>n; for(int array=0; array<n; array++){ cout<<"Enter Array Element"<<(array+1)<<": "; cin>>num[array]; } cout<<"The index of the second Largest Element is: "<<index_Of_Second_Largest_Element(array[]); } int index_Of_Second_Largest_Element(int[] array){ if(num[0]<num[1]){ largest = num[1]; second = num[0];} else{ largest = num[0]; second = num[1];} for (int Array = 2; array< n ; array ++) { if (num[array] > largest) { second = largest; largest = num[array]; } else if (num[array] > second && num[array] != largest){second = num[array];} return second;}}