IS ARMSTRONG OR NOT
#include<iostream>
using namespace std;
int main()
{
int i, sum=0, num1,num2, r;
cout<<"Enter a number: ";
cin>>num1;
num2=num1;
while(num1>0)
{
r=num1%10;
sum=sum+r*r*r;
num1=num1/10;
}
if(num2==sum)
{
cout<<"\n %d is Armstrong number:";
}
else
{
cout<<"\n %d is not Armstrong number:";
}
return 0;
}
0 Comments