Make Your Search Easy ! :) Use me

Friday, March 24, 2017

Armstrong Number

Program to find all Armstrong numbers in a given interval :-


#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<math.h>

void angstrom_find(num)
{
           int dup=num,sum=0,rem;
           for(num;num>0;num=num/10)
                 {
                     rem=num%10;
                           sum=sum+(pow(rem,3));
                   }
               if(sum==dup)
                {
             cout<<setw(4)<<dup<<endl;
                   }
        }

void main()
    {
           int arg1,arg2;
           cout<<"Enter the Limits Within Which Angstrom Nos. are to be Found:";
           cin>>arg1>>arg2;
           for(num=arg1;num<=arg2;++num)
                {
                  angstrom_find(num);
                 }
           getch();
      }

No comments:

Post a Comment