Any number whose digits cube's sum is the same number is called an Armstrong Number.
   Still didn't understand? Don't worry lets understand through an example. 
   If number is 153 then  1^3  + 5^3 +  3^3  = 153  So, these types of numbers are called as
   Armstrong number. Through this program below we will be printing out all the 
   Armstrong numbers  between 100 and 999.                                                        

  Program 

   #include<stdio.h>

   #include<conio.h>

    void main()

   {

    int n,temp,rem,cube=0,sum;

    for(temp=100;temp<=999;temp++)

       {

        sum=0;

        n=temp;

        while(n>0)

           {

            rem=n%10;

            cube=rem*rem*rem;

            sum=sum+cube;

            n=n/10;

            }

     if(temp==sum)

          {

           printf("Armstrong numbers are :  %d\n",temp);

           }

        }

     }  

  Output: 


                         << Back

Post a Comment

Previous Post Next Post