Generate brackets

its working on checking but on submittiing its showing testcases error
#include<bits/stdc++.h>
using namespace std;
void generatepair(char arr[],int i,int o,int c,int n){
if(i==2*n){
arr[i]=’\0’;
cout<<arr<<"\n";
return;
}
else if(o<n){
arr[i]=’(’;
generatepair(arr,i+1,o+1,c,n);
}
if(c<o){
arr[i]=’)’;
generatepair(arr,i+1,o,c+1,n);
}
return;

}
int main() {
int n;
cin>>n;
char arr[100];
generatepair(arr,0,0,0,n);
return 0;
}

Please save your code on ide.codingblocks.com and then share its link.

Check now

why condition of closed bracket is second why not of open brackets?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.