C-Program to print Armstrong numbers between 1 and 500.

If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. for example , 153 = (1*1*1) + (5*5*5) + (3*3*3).

#include<stdio.h>
void main()
{
int n,i,dn,d,temp;
printf("The series of Armstrong numbers from 1 to 500 :  ");
for(i=1;i<=500;i++)
  {
  temp=0;
  n=i;
     do
     {
       d=n%10;
       temp=temp+(d*d*d);
       n=n/10;
     } while(n!=0);
if(i==temp)
printf("\t %d", i);
   }
}