Monday, 1 September 2014

Armstrong number

#include<conio.h>
#include<stdio.h>
main()
{
int a,n,nc,sum=0;
printf("enter any possitive number ");
scanf("%d",&n);
nc=n;
while(nc>0)
{
a=nc%10;
sum=sum+(a*a*a);
nc=nc/10;
}
if(sum==n)
printf("%d is a armstrong number",n);
else
printf("%d is n0t a armstrong number",n);
getch();
return 0;
}

No comments:

Post a Comment