Check if current element is smaller than smallest , the current smallest will become secondSmallest and current element will be the new smallest
if ( arr [ i ] < smallest ) { secondSmallest = smallest ; smallest = arr [ i ] ; }