I am unable to pass Four test cases

Can you please tell what is the problem in my code.

int main() {

long long int n,m;
cin>>n;
m=n;
int nod=0;
int sum=0;
for(int i=0;i<n;i++){
	int r=n%10;
	nod++;
	n=n/10;
}
for(int i=0;i<m;i++){
	int r = m%10;
	sum = sum+pow(r,nod);
	m=m/10;
}

if(sum==m){
	cout<<"true";
}
else
	cout<<"false";
return 0;

}

@rajharsh865 use while and compare sum with original no not m as it became 0 , corrected -


if cleared dont forget to mark resolved :smiley:

1 Like