Delhi's Odd Even

test case is wrong but it is showing right output
what is the correct way to solve it?

#include
using namespace std;
int main() {
int n;
cin>>n;
int no;
while(n>0)
{
cin>>no;
int a;
int sum=0;
//for(int i=0;i<no;i++)
while(no>0)
{
a=no%10;
sum=sum+a;
no=no/10;
}
if(sum%4==0 || sum%3==0)
{
cout<<“Yes”<<endl;
//break;
}
else
{
cout<<“No”<<endl;
break;
}

}

return 0;

}

Hi nitin
Save ur code to online ide of coding block and share the link here

Hi Sharad

In the else statement do not use break statement it will exit from the above while loop if still n>0
Also use n-- for the outer while loop

Then it is showing wrong output. Can you give me the correction one.

check this


i have commented ur mistake and rectify it

1 Like