#include
using namespace std;
int main()
{ int n,no;
cin>>n;
int i=1;
while(i<=n)
{
cin>>no;
int sum=0;
while(no>0)
{
int r=no%10;
sum=sum+r;
no=no/10;
}
if(sum%2==0 && sum%4==0)
cout<<“Yes”<<endl;
else if(sum%2!=0 && sum%3==0)
cout<<“Yes”<<endl;
else
cout<<“No”<<endl;
i=i+1;
}
}
Delhi odd even program
Check now=>
Question wasn’t clear to you, you have to take each digit as a number and then have to add, dry run this code by me. You will get the error.
it still not working if i enter number 12589 it is printing yes as its sum is odd and it is not divisible by 3 but still it is printing “yes”
See when you enter 12589 your es is 10 & os is 15 in which 15 is divisible by 3 but es is not divisible by 4, so since out of these 2 conditions one is correct. We will print yes.
Cause
os is 9 by adding 9
es is 8 by adding 8
os is 14 by adding 5
es is 10 by adding 2
os is 15 by adding 1
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.