#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;
}
please dry run this prrogram i could'nt understand.......
ReplyDeletewhy use n/10....plz explain
ReplyDeleten/10 is used for removing first digit and calculating s for next digits
ReplyDeletehye, nice content yr thanx for sharing
ReplyDeletethis code is only for three digit number upload the code for "n" number of digits
ReplyDeleteFound 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
ReplyDeleteGreat 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.
Armstrong Program in C++
ReplyDeleteArmstrong 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.