#include<iostream.h>
int main()
{
int sum,temp,rem,n;
cout<<"Enter the number \n";
cin>>n;
cout<<" Entered number is \t";
cout<<n;
cout<<"\n";
sum=0;
temp=n;
do
{
rem=n%10;
n=n/10;
sum=sum+rem*rem*rem;
}while(n!=0);
if(sum==temp)
cout<<"This is Armstrong number.\n";
else
cout<<"This is not Armstrong number.\n";
return 0;
}
int main()
{
int sum,temp,rem,n;
cout<<"Enter the number \n";
cin>>n;
cout<<" Entered number is \t";
cout<<n;
cout<<"\n";
sum=0;
temp=n;
do
{
rem=n%10;
n=n/10;
sum=sum+rem*rem*rem;
}while(n!=0);
if(sum==temp)
cout<<"This is Armstrong number.\n";
else
cout<<"This is not Armstrong number.\n";
return 0;
}
Output:-
Enter the number
371
Entered number is 371
This is Armstrong number.
No comments:
Post a Comment