#include
using namespace std;
int main() {
int N;
int no;
cin>>N;
while(N>0) {
cin>>no;
int s=0;
while(no>=0) {
int p = no%10;
s=s+p;
no=no/10;
}
((s%2==0 && s%4==0) || (s%2!=0 && s%3==0))? cout<<“YES” : cout<<“NO”;
N=N-1;
}
return 0;
}
I have written this code for delhi's even odd. But it says to think much efficiently. can you help me by giving some clues
it is mentioned that if the sum of digits which are even is divisible by 4 or sum of digits which are odd in that number is divisible by 3. which means you need to maintain 2 sum odd_sum and even_sum and add even digits in even_sum, odd digits in odd_sum and check the condition
Code
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.