C program to find Armstrong Numbers between 1 and 1000.


#include<stdio.h>
int main()
{
  int x,y,i,rem,sum=0;
  printf("\n The Armstrong numbers between 1 and 1000 are:");
  for(i=1;i<=1000;i++)
  {
     sum=0;
     x=i;
     y=i;
     while(x>0)
       {
        rem=x%10;
        sum=sum+rem*rem*rem;
        x=x/10;
       }
        if(sum==y)
        printf("\n %d",sum);
  }
   return 0;
  }


***Input && Output***


Post a Comment

0 Comments