for two 's complement go from right to left in  ones complement and if we get 1 make, we make  them 0 and keep going left when we get first  0, make that 1 and go out of loop
twos = ones ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( ones [ i ] == '1' ) twos [ i ] = '0' ; else { twos [ i ] = '1' ; break ; } }