Armstrong Number or Not in C++.
#include<iostream>
using namespace std;
int main()
{
int arm=0,a,b,c,d,num;
cout<<"Enter any num: ";
cin>>num;
d=num;
while(num>0)
{
a=num%10;
num=num/10;
arm=arm+a*a*a;
}
if(arm==d)
{
cout<<"It is Armstrong";
}
else
{
cout<<"It is not Armstrong";
}
return 0;
}
OUTPUT
Enter any num: 371
It is Armstrong
No comments:
Post a Comment
Please do not any spam link in Comment Box