/* Average/mean values of two number using Friend Function */
#include<iostream>
using namespace std;
class Average
{
int a,b;
public:
void accept()
{
cout<<"\n\n Enter any two number: ";
cin>>a>>b;
}
void display()
{
cout<<"\n\n A: "<<a;
cout<<"\n B: "<<b;
}
friend void mean(Average A);
};
void mean(Average A)
{
float c;
c=(A.a+A.b)/2.0;
cout<<"\n Average: "<<c;
}
int main()
{
Average A;
A.accept();
A.display();
mean(A);
return 0;
}
#include<iostream>
using namespace std;
class Average
{
int a,b;
public:
void accept()
{
cout<<"\n\n Enter any two number: ";
cin>>a>>b;
}
void display()
{
cout<<"\n\n A: "<<a;
cout<<"\n B: "<<b;
}
friend void mean(Average A);
};
void mean(Average A)
{
float c;
c=(A.a+A.b)/2.0;
cout<<"\n Average: "<<c;
}
int main()
{
Average A;
A.accept();
A.display();
mean(A);
return 0;
}