Friday 10 February 2012

how to check the given number is amstrong or not


#include<stdio.h>
#include<math.h>
main()
{
int a,i,n,sum=0,am;
printf("enter your number:");
scanf("%d",&n);
a=n;
while(n>0)
{
i=n%10;
sum=sum+pow(i,3);
n=n/10;
}
if(sum==a)
printf("%d is amstrong",a);
else
printf("%d is not amstrong",a);
}

No comments:

Post a Comment