If the length of resultant string is less than N than add a character ' a '
for ( int i = total ; i < N ; i ++ ) { ans += ' a ' ; } string reverse = " " ; int Len = ans . Length - 1 ; while ( Len >= 0 ) { reverse = reverse + ans [ Len ] ; Len -- ; }