Find second largest
Hi anyone know how to find second largest #include <iostream> using namespace std; int index_Of_Second_Largest_Element(int x[]){ int first; int second; int temp; int len = sizeof(x)/sizeof(x[0]); for(int i = 0; i < len ; i++){ if(i < 1) { if(x[i] > x[i+1]) { first = x[i]; second = x[i+1]; } else{ first = x[i+1]; second = x[i]; } } else if(i > 1){ if(x[i] > first){ second = first; first = x[i]; } } } return second; } int main () { int num [] = {5,9,8,2,3,11,10}; int second_larger = index_Of_Second_Largest_Element (num); cout << "Index of Second Largest Element " << second_larger << endl; return 0; }