C++ program for loop Armstrong number

 

#include <iostream>
using namespace std;
int main()
{
int n,r,sum=0,temp;
cout<<"enter any number";
cin>>n;
temp=n;

for(n!=0;n>0;)

{
r=n%10;
sum=sum+(r*r*r);
n=n/10;

}
if(temp==sum)
{
cout<<"Armstrong number";
}
else
{
cout<<"not Armstrong number";
}
}

Comments

Popular Posts