Using friend function division between two number in c + +
using namespace std;
#include<iostream>
#include<conio.h>
class xyz;
class abc
{
private:
int a;
int b;
public:
void input();
friend void div(abc,xyz);
};
void abc::input()
{
cout <<"\n enter the value of a:";
cin>>a;
cout<<"\n enter the value of b:";
cin>>b;
}
class xyz
{
private:
int x;
int y;
public:
void input();
friend void div(abc,xyz);
};
void xyz::input()
{
cout<<"\n enter the value of x:";
cin>>x;
cout<<"\n enter the value of y:";
cin>>y;
}
void div(abc a1,xyz x1)
{
int t,s;
if(a1.a>x1.x)
{
t=a1.a/x1.x;
cout<<"\n "<<"a"<<"/"<<"x"<<"="<<t;
}
if(a1.b>x1.y)
{
s=a1.b/x1.y;
cout<<"\n "<<"b"<<"/"<<"y"<<"="<<s;
}
}
int main()
{
abc A;
xyz X;
A.input();
X.input();
div(A,X);
return 0;
}
#include<iostream>
#include<conio.h>
class xyz;
class abc
{
private:
int a;
int b;
public:
void input();
friend void div(abc,xyz);
};
void abc::input()
{
cout <<"\n enter the value of a:";
cin>>a;
cout<<"\n enter the value of b:";
cin>>b;
}
class xyz
{
private:
int x;
int y;
public:
void input();
friend void div(abc,xyz);
};
void xyz::input()
{
cout<<"\n enter the value of x:";
cin>>x;
cout<<"\n enter the value of y:";
cin>>y;
}
void div(abc a1,xyz x1)
{
int t,s;
if(a1.a>x1.x)
{
t=a1.a/x1.x;
cout<<"\n "<<"a"<<"/"<<"x"<<"="<<t;
}
if(a1.b>x1.y)
{
s=a1.b/x1.y;
cout<<"\n "<<"b"<<"/"<<"y"<<"="<<s;
}
}
int main()
{
abc A;
xyz X;
A.input();
X.input();
div(A,X);
return 0;
}
Comments
Post a Comment