#include<stdio.h>
#include<conio.h>
#include<math.h>
int armstrong(int a)
{
int x,s=0,m=0;
x=a;
while(x!=0)
{
m++;
x=x/10;
}
while(a!=0)
{
s=s+pow((a%10),m);
a=a/10;
}
return s;
}
void main()
{
int a;
puts("Enter your number");
scanf("%d",&a);
if(a==armstrong(a))
puts("This is armstrong number");
else
puts("This is not armstrong number");
}
Comments
Post a Comment