wap to check armstrong in c++
#include<iostream>
using namespace std;
int main()
{
int n,temp=0,sum=0,rem=0,c;
cout<<"Enter numbers upto which:"<<endl;
cin>>c;
temp=c;
rem=temp%10;
cout<<rem;
while(temp!=0)
{
rem=temp%10;
sum=sum+(rem*rem*rem);
temp=temp/10;
}
if(sum==c)
cout<<"number is armstrong"<<endl;
else
cout<<"it is not armstrong"<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int n,temp=0,sum=0,rem=0,c;
cout<<"Enter numbers upto which:"<<endl;
cin>>c;
temp=c;
rem=temp%10;
cout<<rem;
while(temp!=0)
{
rem=temp%10;
sum=sum+(rem*rem*rem);
temp=temp/10;
}
if(sum==c)
cout<<"number is armstrong"<<endl;
else
cout<<"it is not armstrong"<<endl;
return 0;
}
========================================================================
** if there is no program available then pls. go to top right section and search it
#dynamiteRohit thanks :)
No comments:
Post a Comment