You are on page 1of 1

# include <stdio.

h>
# include <conio.h>
void main()
{
int i, a, r, s, n ;
clrscr() ;
printf("Enter the limit : ") ;
scanf("%d", &n) ;
printf("\nThe armstrong numbers are :\n\n") ;
for(i = 0 ; i <= n ; i++)
{
a = i ;
s = 0 ;
while(a > 0)
{
r = a % 10 ;
s = s + (r * r * r) ;
a = a / 10 ;
}
if(i == s)
printf("%d\t", i) ;
}
getch() ;
}

Output of above program Enter the limit : 1000


The armstrong numbers are :
0
1
153
370
371

407

You might also like