Output is coming correct but testcases are coming incorrect

plz help this is the subset easy question from challenges

Hello @yashsingh9289,

Please, share your code.
That will help me to identify your mistake.

Possible mistake:
You might be passing sum as 0, initially.
So, it will be true for sure for the case when you would add no element to sum.
Example:
2
1 2 3 4

Hope, this would help.

#include
using namespace std;
void sub(char arr[],char out[],bool &ischeck,int opos,int spos)
{
if(arr[spos]==’\0’)
{int sum=0;
out[opos]=’\0’;
for(int i=0;out[i]!=’\0’;i++)
{
sum=sum+(out[i]-β€˜0’);
}if(sum==0&&out[0]!=’\0’)
{

    ischeck=true;
}

return;
}

out[opos]=arr[spos];

sub(arr,out,ischeck,opos+1,spos+1);
sub(arr,out,ischeck,opos,spos+1);

}
int main()
{int t;cin>>t;
int n;cin>>n;
char arr[100],out[100];
bool ischeck=false;
for(int j=1;j<=t;j++)
{for(int i=0;i<n;i++)
{cin>>arr[i];}
sub(arr,out,ischeck,0,0);
if(ischeck) {cout<<β€œYES”<<endl;ischeck=false;}
else {cout<<β€œNO”<<endl;ischeck=true;}
}

}

Hello @yashsingh9289,

Please share your code using Online Coding Blocks IDE.
The way you have shared it has introduced many syntax errors to it.
STEPS:

  1. Paste it on https://ide.codingblocks.com/
  2. Save it there.
  3. Share the URL generated.
    I am waiting for your reply.

i have given my code but didn’t get reply

Hello @yashsingh9289,

Yes, you have shared your code. But the way you have shared it has introduced many syntax errors to it.

Please share your code using Online Coding Blocks IDE.
STEPS:

  1. Paste it on https://ide.codingblocks.com/
  2. Save it there.
  3. Share the URL generated.

I am waiting for your reply.

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.