Put the last element back
arr [ n - 1 ] = last ; if ( ( i < n - 1 ) || ( arr [ n - 1 ] == key ) ) Console . WriteLine ( key + " ▁ is ▁ present " + " ▁ at ▁ index ▁ " + i ) ; else Console . WriteLine ( " Element ▁ Not ▁ found " ) ; }