/*Armstrong Number using Friend Function*/
#include<iostream>
using namespace std;
class Armstrong
{
int a;
public:
void accept()
{
cout<<"\n\n Enter any number: ";
cin>>a;
}
void display()
{
cout<<"\n\n A: "<<a;
}
friend void arm(Armstrong A);
};
void arm(Armstrong A)
{
int rem,rev=0,num;
num=A.a;
while(num>0)
{
rem=num%10;
rev=(rem*rem*rem)+rev;
num=num/10;
}
if(rev==A.a)
cout<<"\n\n Armstrong Number";
else
cout<<"\n\n Not an Armstrong Number";
}
int main()
{
Armstrong A;
A.accept();
A.display();
arm(A);
return 0;
}
#include<iostream>
using namespace std;
class Armstrong
{
int a;
public:
void accept()
{
cout<<"\n\n Enter any number: ";
cin>>a;
}
void display()
{
cout<<"\n\n A: "<<a;
}
friend void arm(Armstrong A);
};
void arm(Armstrong A)
{
int rem,rev=0,num;
num=A.a;
while(num>0)
{
rem=num%10;
rev=(rem*rem*rem)+rev;
num=num/10;
}
if(rev==A.a)
cout<<"\n\n Armstrong Number";
else
cout<<"\n\n Not an Armstrong Number";
}
int main()
{
Armstrong A;
A.accept();
A.display();
arm(A);
return 0;
}