/* to read a number and find its armstrong */
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int n,x,sum=0,num;
printf("Enter number: ");
scanf("%d",&n);
num=n;
while(n!=0)
{
x=n%10;
sum+=(float)pow(x,3);
n/=10;
}
if (sum==num)
printf("%d is armstrong",num);
else
printf("%d is not armstrong",num);
system("pause");
return 0;
}
No comments:
Post a Comment