Program to find Armstrong numbers with in particular range
#include<stdio.h> #include<string.h> void armstr(int); main() { int min,max,i=0,n,a; printf("enter min and max range...\n"); scanf(" %d %d",&min,&max); for(i=min;i<=max;i++) { //n=min; armstr(i); //temp=n; } } void armstr(int n) { //printf("n=%d\n",n); int temp,rem=0,sum=0; temp=n; while(n>0) { rem=n%10; sum=sum+(rem*rem*rem); n=n/10; } if(sum==temp) printf("armstrong:%d\n",sum); }OutPut:
enter min and max range... 100 500 armstrong:153 armstrong:370 armstrong:371 armstrong:407