Delhi's Odd Even Error

I think I have written the correct code and my sample test cases are passing for the same. Can you please see the code and tell me my error

#include
using namespace std;
int main() {
int n;
cin>>n;
while(n–)
{
long sum=0,n1;
cin>>n1;
while(n1!=0)
{
long r=n1%10;
sum+=r;
n1=n1/10;
}
if(sum>0)
{
if(sum%2==0)
{
if(sum%4==0)
cout<<“Yes”<<endl;
else
cout<<“No”<<endl;
}
else if(sum%2!=0)
{
if(sum%3==0)
cout<<“Yes”<<endl;
else
cout<<“No”<<endl;
}
}
}
return 0;
}

@TheAlgo copy your code on ide and then share it in this thread so we can help you asap

Yes I will do it now iteself

@TheAlgo happy coding

#include
using namespace std;
int main() {
int n;
cin>>n;
while(n–)
{
long sum=0,n1;
cin>>n1;
while(n1!=0)
{
long r=n1%10;
sum+=r;
n1=n1/10;
}
if(sum>0)
{
if(sum%2==0)
{
if(sum%4==0)
cout<<“Yes”<<endl;
else
cout<<“No”<<endl;
}
else if(sum%2!=0)
{
if(sum%3==0)
cout<<“Yes”<<endl;
else
cout<<“No”<<endl;
}
}
}
return 0;
}

@TheAlgo save you code here cb.lk/ide then share it here.it will generate a url share that url here

https://ide.codingblocks.com/s/71480

@TheAlgo hey dhiraj
For ex if you are given a no.:

982452

then maintain 2 variables evesum=0, oddsum = 0 ;
and they will be:

                9   +   8   +   2   +   4   +   5   +   2

evesum = 8 + 2 + 4 + 2 = 16
oddsum = 9 + 5 = 14
if((evesum%4==0)||(oddsum%3==0)){
cout<<“Yes”<<endl;
}else{
cout<<“No”<<endl;
}

I interpreted the question in the wrong way

Hi Dhiraj

If your doubt is resolved then please mark it as resolved in your online course’s ask doubt section.