Please Tell Where I am going wrong in Armstrong Number Problem.I used int and both long int but only 60% test cases are passing?

#include
#include<math.h>
using namespace std;
int main() {
long int remainder;
long int N;
long int sum = 0;
cin>>N;
long int X=N;
long int digits = 0;
while(N>0){
N = N/10;
digits = digits + 1;
}
while(N>0){
remainder = N%10;
N = N/10;
sum = sum + pow(remainder,digits);
}
if(sum == N){
cout<<“true”<<endl;
}

return 0;

}

hello @yashratnani6

value of N will be zero after first while loop so ur second while loop will never run.

store value of n in some variable and then use that variable

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.