Why my code getting WA?

#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool checksum(int a[],int n)
{
unordered_set s;
int pre=0;
for(int i=0;i<n;i++)
{
pre += a[i];
if(pre=0 or s.find(pre)!=s.end())
{
return true;

     }
         s.insert(pre);
           for(auto it=s.begin();it!=s.end();it++)
         {
             cout<<*it;
         }
         cout<<endl;
     }
     return false;

}
int main()
{
//lets play

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];

}
if(checksum(a,n))
{
cout<<“true”;
}
else
{
cout<<“false”;
}
}

please reply as soon as possible…

#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool checksum(int a[],int n)
{
unordered_set s;
int pre=0;
for(int i=0;i<n;i++)
{
pre += a[i];
if(pre=0 or s.find(pre)!=s.end())
{
return true;

     }
         s.insert(pre);
         
     }
     return false;

}
int main()
{
//lets play

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];

}
if(checksum(a,n))
{
cout<<“true”;
}
else
{
cout<<“false”;
}
}

send your code on coding blocks ide

HOW_______________________________________

Paste your code on this https://ide.codingblocks.com/
press ctrl+S
then copy the URL and send here

Hey ,error is in this line
it should be pre==0
If this doen’t work then send the code on ide.

1 Like

THANKX’’’’’’’’’’’’’’’’’’

1 Like

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.