Generate parenthesis

Given an integer ‘n’. Print all the possible pairs of ‘n’ balanced parentheses.
The output strings should be printed in the sorted order considering ‘(’ has higher value than ‘)’.

Input Format
Single line containing an integral value ‘n’.

Constraints
1<=n<=11

Output Format
Print the balanced parentheses strings with every possible solution on new line.

Sample Input
2
Sample Output
()()
(())

solution link: https://ide.codingblocks.com/s/287711

how to print output in sorted order?

@1799sanya


just interchanges the if loop
dont forget to hit like and mark resolved if cleared :smiley: