Findex the largest 2 elements
for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second ) { second = arr [ i ] ; } } cout << " n ▁ = ▁ " << first << " ▁ and ▁ r ▁ = ▁ " << second ; }