Driver code
int main ( ) { int array [ ] = { -12 , -11 , -13 , -5 , -6 , 7 , 5 , 3 , 6 } ; int length = ( sizeof ( array ) / sizeof ( array [ 0 ] ) ) ; int countNegative = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( array [ i ] < 0 ) countNegative ++ ; } std :: cout << " array : ▁ " ; printArray ( array , length ) ; rearrange ( array , 0 , ( length - 1 ) ) ; reverse ( array , countNegative , ( length - 1 ) ) ; std :: cout << " rearranged ▁ array : ▁ " ; printArray ( array , length ) ; return 0 ; }