56. C Program To check a Number is Armstrong number or Not.
How does this program work?
- This Program is used to check the given number is armstrong number or not.
Here is the code
#include <stdio.h>
int main()
{
int n,n1,r,num=0;
printf("Enter a number\n");
scanf("%d",&n );
n1=n;
while(n1!=0)
{
r=n1%10;
num=num+(r*r*r);
n1=n1/10;
}
if(num==n)
printf("%d is an amstrong number\n",n );
else
printf("%d is not an amstrong number\n",n );
}