Delhi odd even 1 test case not working

What is wrong in the code?

I/P format

2

12345

13141

Program–>

using namespace std;

int main()
{

 int n,cno,sum=0,ans=0,i,m;
	 cin>>n;
	 cout<<endl;

	 for(i=1;i<=n;i++)
	 {	
		 cin>>cno;	
			while(cno>0)
				{
					m=cno%10;
					m%2==0?sum+=m:ans+=m;
					cno=cno/10;

				}
				if((sum%4==0) || (ans%3==0))
					{
						cout<<"Yes"<<endl;
					}	
				else{
					cout<<"No"<<endl;
					}
			 }
return 0;

}

Initialize sum=0,ans=0 inside the for loop and then check. Because they must be reinitialized for each test case.

1 Like

Ya it worked thanks a lot!!

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.

1 Like