/* Even or odd using Friend Function */
#include<iostream>
using namespace std;
class EvenorOdd
{
int a;
public:
void accept()
{
cout<<"\n\n Enter any number: ";
cin>>a;
}
void display()
{
cout<<"\n\n A: "<<a;
}
friend void check(EvenorOdd e);
};
void check(EvenorOdd e)
{
if(e.a%2==0)
cout<<"\n\n Even";
else
cout<<"\n\n Odd";
}
int main()
{
EvenorOdd e;
e.accept();
e.display();
check(e);
return 0;
}
#include<iostream>
using namespace std;
class EvenorOdd
{
int a;
public:
void accept()
{
cout<<"\n\n Enter any number: ";
cin>>a;
}
void display()
{
cout<<"\n\n A: "<<a;
}
friend void check(EvenorOdd e);
};
void check(EvenorOdd e)
{
if(e.a%2==0)
cout<<"\n\n Even";
else
cout<<"\n\n Odd";
}
int main()
{
EvenorOdd e;
e.accept();
e.display();
check(e);
return 0;
}