source file name: Armnos.C
void main()
{
int n,d,sum=0;
int temp;
clrscr();
printf("\n List of Armstrong numbers: 1 to 999 ");
for(n=100;n<=999;n++)
{
sum=0;
temp=n;
while(temp>0)
{
d=temp%10;
sum=sum+(d*d*d);
temp=temp/10;
}
if(sum==n)
printf("\n %d ",n);
}
getch();
}
output:
0 Comments
Post a Comment