//Code
#include<stdio.h>
main()
{
int n,sum=0,k,r;
printf("Enter No To Check\nArmstrong Number OR Not\n");
scanf("%d",&n);
k=n;
while(n>0)
{
r=n%10;
sum=r*r*r+sum;
n=n/10;
}
if(k==sum)
printf("%d is an Armstrong no\n",sum);
else
printf("NOT an Armstrong no");
}
#include<stdio.h>
main()
{
int n,sum=0,k,r;
printf("Enter No To Check\nArmstrong Number OR Not\n");
scanf("%d",&n);
k=n;
while(n>0)
{
r=n%10;
sum=r*r*r+sum;
n=n/10;
}
if(k==sum)
printf("%d is an Armstrong no\n",sum);
else
printf("NOT an Armstrong no");
}
No comments:
Post a Comment