Armstrong number

sir ,what is the error in this code

code: https://ide.codingblocks.com/s/373302

what you have done in this code??

a=a*!0;

this is just multiply with 1

Reference Code

Sir, That was by mistake it is supposed to be a=a*10; otherwise iam

Sir, That was by mistake it is supposed to be a=a*10; otherwise I am not able to find any other error. CODE-https://ide.codingblocks.com/s/373711

what you have done here

while(x>a)

    {

        n=x%b;

        b=b*10;

        n=n/a;

        a=a*10;

        count++;

    }

are you want to calculate the no of digits in a number?
then correct way to do that is

// first find the length of num

    int num=n;

    int len=0;

    while(num>0){

        len++;

        num/=10;

    }

now after calculating no of digit of a number

// now check wheter it is armstrong number of not
    int ans=0;

    num=n;

    while(num>0){

        int rem=num%10;

        ans+=pow(rem,len);

        num=num/10;

    }

    if(ans==n)cout<<"true\n";

    else cout<<"false\n";

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.