WAP to Check Whether the Given Number is an Armstrong Number .

#include<stdio.h>

#include<math.h>

int main()

{

    int a,b,r,sum;

    sum=0;

    printf("Enter the number = ");

    scanf("%d",&a);

    b=a;

    while(a!=0)

    {

        r=a%10;

        a=a/10;

        sum=sum+(r*r*r);

    }

    if(sum==b)

    {

        printf("\nIt is an armstrong number \n");

    }

    else

        {

        printf("\nIt is not a armstrong number\n ");

    }

}
WAP to Check Whether the Given Number is an Armstrong Number . WAP to Check Whether the Given Number is an Armstrong Number . Reviewed by Unknown on 03:37 Rating: 5

No comments:

Powered by Blogger.