[Solved] wrong output in armstrong number program in c


for each value sum has to be zero that is first correction.and i has to be assigned to variable temp because i value has to be checked if it is armstrong number or not.do the changes it will work.

#include<stdio.h>
int main()
 {
   int i, rem, sum=0, temp;
   for(i=0; i<1000; i++) 
    {
        temp = i;
        sum=0;
        while(temp>0)
         {
             rem = temp%10;
             sum += rem*rem*rem;
             temp /= 10;
          }

       if (sum == i)
          {
             printf("\n%d ", i);
           }

}

Output
0
1
153
370
371
407

solved wrong output in armstrong number program in c