#include <iostream>
using namespace std;
class A
{
public :
int x, y;
void getdata ()
{
cout <<"Enter the value of x and y: ";
cin>>x>>y;
cout <<x<<" \t"<<y<<endl;
}
};
class B : public A
{
public :
void product ()
{
cout <<"product xy= "<<x*y<<endl;
}
};
class C :public A
{
public :
void sum()
{
cout <<"Sum x+y= "<<x+y<<endl;
}
};
class D:public B
{
public :
int z;
void productz()
{
cout <<"Enter the value of z : ";
cin >>z;
cout <<z<<endl;
cout <<"Result xyz= "<<x*y*z<<endl;
}
};
int main() {
B o;
C o1;
D o2;
o. getdata ();
o. product ();
o1.getdata();
o1.sum();
o2.getdata();
o2.product();
o2.productz();
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: