Check Armstrong Number program using C
int main()
{
int n,s=0,t;
printf("Enter number to be checked");
scanf("%d",&n);
t=n;
do
{
s=s+pow((n%10),3);
printf("%d",pow((n%10),3));
printf("%d\n",s);
n/=10;
}
while(n);
if(s==t)
printf("It is a Armstrong number");
else
printf("It is not an Armstrong number");
getch();
}
No comments:
Post a Comment