This is my code it is giving correct output but some test cases aren’t passed can i know why
Is Armstrong number
you are using a single variable num
and changing the value of num
after this loop
while(num>0){
r = num%10;
num /=10;
sum += pow(r, digit);
}
num will be zero hence you lose the original number
so further operations will not be done
Correct Way is to make a seperate variable
Modified Code