/* C program to find Armstrong Numbers between 100 and 999 */ void main() { int i,n,sum,r; printf("\nThe ARMSTRONG numbers from 100-999 are: "); i = 100; while(i <= 999) { sum = 0; n = i; while(n > 0) { r = n % 10; sum = sum + (r * r * r); n = n / 10; } if(i == sum) printf("\n\t\t\t\t\t%d",i); i = i + 1; } }
Output |
No comments:
Post a Comment