Welcome..!!

Please visit http://csprograms.in/ for more Computer Science programs.

Tuesday 13 March 2012

6. C++ program to find Armstrong number


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

8 comments:

  1. please dry run this prrogram i could'nt understand.......

    ReplyDelete
  2. n/10 is used for removing first digit and calculating s for next digits

    ReplyDelete
  3. hye, nice content yr thanx for sharing

    ReplyDelete
  4. this code is only for three digit number upload the code for "n" number of digits

    ReplyDelete
  5. Found your blog. Its really nice on C++ programming. Its a great tutorial for the beginners. Really liked it. Thank you for all the information.

    ReplyDelete

  6. Great information here. Thank you for sharing. If you are ever in a need of colorado
    24 hour
    Services we are Aurora Locksmith Services. You can find us at auroralocksmithco.com.com or call us at: (720) 220-4851.

    ReplyDelete
  7. Armstrong Program in C++

    Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits is equal to the number itself.
    For example 153 is armstrong number, 132 is not prime number. Armstrong program in c++ is very simple and easy to write.

    ReplyDelete