Is armstrong number

#include
#include<math.h>
using namespace std;

int main()
{
int rem=0,no,p,r=0,ans=0,count=0;
cin>>no;
no=p;
while(p>0)
{
p=p%10;
count++;
p=p/10;
}
cout<<“count=”<<count<<endl;

while(no>0)
{
    rem=no%10;
    ans=ans+pow(rem,count);
    no=no/10;
}

if(ans==no)
{
    cout<<"true"<<endl;
}
else
{
    cout<<"false"<<endl;
}
return 0;

}

What is wrong in this code logic wise??

@dsdishu99
Hello deeksha,
a) the issue is in this code
image

remove p=p%10 from ur while loop

b) store no in some temporary variable because no after this
image
will become zero

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.