google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C++ Program to check whether number is Armstrong number

Saturday, March 1, 2014

C++ Program to check whether number is Armstrong number

#include<iostream.h>
int main()
{
      int sum,temp,rem,n;
     cout<<"Enter the number \n";
     cin>>n;
     cout<<" Entered number is \t";
     cout<<n;
     cout<<"\n";
     sum=0; 
     temp=n;
      do
        {
                rem=n%10;
                n=n/10;
                sum=sum+rem*rem*rem;
           }while(n!=0);
     if(sum==temp)
            cout<<"This is Armstrong number.\n";
   else
           cout<<"This is not Armstrong number.\n";
return 0;
}

Output:-
Enter the number
371
Entered number is    371
This is Armstrong number.

No comments:

Post a Comment

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...