Giving test case not completed

whats wrong in my code

Hey @kshitijkumar7548_da7d29c5890bbfd8 there is a very small mistake in your code that you are modifying n by dividing it by 10 and using this modified value .
basically you are making n=0 using a while(n!=0) loop and after end of this loop n=0 and you are again using this n=0 in another while loop which would never run as condition n!=0 turns false and while loop will not run

instead you should store this value of n and modify this copy of n and not n directly

the corrected code will be

#include
#include<math.h>
using namespace std;
void armstrong(int n){
int digit=0;
int sum=0;
int a;
int temp=n;
while(n!=0){
digit++;
n=n/10;
}
n=temp;
while(n!=0){
a=n%10;
sum=sum+pow(a,digit);
n=n/10;
}
n=temp;
if(sum==n){
cout<<“True”;
}

else{
    cout<<"False";
}

}
int main(){
int n;
cin>>n;
armstrong(n);

return 0;
}

hope it helps

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.