#include
void main()
{
int i,d,n,s;
clrscr();
printf("Amstrong Number Between 1 to 999.\n");
for(i=1;i<=999;i++)
{
n=i;
s=0;
while(n!=0)
{
d=n%10;
s=d*d*d+s;
n=n/10;
}
if(i==s)
printf("%d\n",s);
}
getch();
}
Output
Amstrong Number Between 1 to 999.
1
153
370
371
407
No comments:
Post a Comment