#include<iostream>
using namespace std;
int main()
{
int x=0;
int sum=0;
int y;
int a;
int b;
cout<<"enter a number:";
cin>>x;
b=x;
while(x>0)
{
a=x%10;
y=a*a*a;
x=x/10;
sum+=y;
}
if(sum==b)
{
cout<<"The Number is Armstrong";
}
else
{
cout<<"The Number is Not Armstrong";
}
return 0;
}
*****************************************
output:
using namespace std;
int main()
{
int x=0;
int sum=0;
int y;
int a;
int b;
cout<<"enter a number:";
cin>>x;
b=x;
while(x>0)
{
a=x%10;
y=a*a*a;
x=x/10;
sum+=y;
}
if(sum==b)
{
cout<<"The Number is Armstrong";
}
else
{
cout<<"The Number is Not Armstrong";
}
return 0;
}
*****************************************
output:
Comments
Post a Comment