#include
using namespace std;
int main() {
int n,r,temp,sum=0;
cin>>n;
while(n!=0){
r=n%10;
sum+=(rrr);
n=n/10;
}
if(sum==n){
cout<<“true”;
}
else{
cout<<“false”;
}
return 0;
}
This code pass only three test cases
#include
using namespace std;
int main() {
int n,r,temp,sum=0;
cin>>n;
while(n!=0){
r=n%10;
sum+=(rrr);
n=n/10;
}
if(sum==n){
cout<<“true”;
}
else{
cout<<“false”;
}
return 0;
}
This code pass only three test cases
Your n becomes 0 in the while loop. So the condition sum==n will never be true.
Also we never multiply 3 variables like pqr in C++. We always write - pqr
Please share the code.I am not understanding.
There you go -
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.