I'm a begineer. I wrote this program to write program to write armstrong numbers from 1 to 10000(which should work uptp any number if the range of "i" is increased) but the problem is that it doesn't show one specific armstrong number 153 only. Except that it works like a charm. Please help me ASAP, I have my exams tomorrow...
insert
Code:
#include<stdio.h>
#include<math.h>
int main()
{
int i, count, ctemp, atemp, rev,paw, total;
for(i=1; i<10000; i++){
ctemp=i;
count=0;
while(ctemp!=0){
ctemp=ctemp/10;
count++;
}
atemp=i;
total=0;
rev=0;
paw=0;
while(atemp!=0){
rev=atemp%10;
paw=pow(rev,count);
total= paw+ total;
atemp=atemp/10;
}
if(total==i){
printf("%d \n", i);
}
}
return 0;
}