i am bit confused how to implement in loop…
PLEASE correct my code by sending pseudo core
@sonu28sharma99 You have implemented it correctly but you haven’t taken any input from the test case. Do it and you’ll be able to get an AC.
#include using namespace std; int main() { int n; cin>>n; int r,even=0,odd=0,sum=0; while(n>0) { r=n%10; if(r%2==0) even=even+r; else odd=odd+r; n=n/10; } if(odd%3==0 || even %4==0) cout<<“yes”; else cout<<“no”; return 0; }
@sonu28sharma99 You are not adding up the sum of even and odd digits. Use a while loop to add each digit of the number to either oddsum or evensum.
Your other part of code is correct.
I’m not understanding what you say please correct it…
@sonu28sharma99
Do this
int oddsum = 0, evensum=0;
while (n != 0)
{
If(n%10)
oddsum = oddsum + n % 10;
Else
evensum = evensum + n % 10;
n = n/10;
}
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.