You are on page 1of 4

OOPM LAB 10

Name :Sujal shah SAP ID : 60002210073 Batch : E1-2

1. Code :

#include<iostream>
using namespace std;

class variable
{
public:
static int value;

void decrease()
{
cout<<"The decremented value is : "<<--value<<endl;
}
};

int variable :: value = 5;


int main()
{
variable object1;
variable object2;
variable object3;

cout<<"The original value is : "<<object1.value<<endl;

object1.decrease();
object2.decrease();
object3.decrease();

return 0;
}

Output :
2. Code :

#include<iostream>

using namespace std;

class shape
{
public:
int l,b,h,s;

int arear()
{
l = 5;
b = 6;
cout<<"The area of the rectangle is : "<<l*b<<endl;
}

int areas()
{
s = 15;
cout<<"The area of the square is : "<<s*s<<endl;
}

int areac()
{
l = 4;
b = 6;
h = 9;
cout<<"The area of the cuboid is : "<<2*(l*b+b*h+h*l)<<endl;
}
};

int main()
{
shape rectangle;
shape square;
shape cuboid;

rectangle.arear();
square.areas();
cuboid.areac();
}

Output :
3. Code :

#include<iostream>

using namespace std;

class parent
{
public:
int m,n;

int add()
{
m = 6;
n = 9;
int s = m+n;
cout<<"The two numbers are "<<m<<" and "<<n<<endl;
}
};

class child : public parent


{
public:

int s;
int sum()
{
cout<<"The sum of the two numbers is : "<<6+9<<endl;
}
};

class grandchild : public child


{
public:

int show()
{
cout<<"This is an example of Multilevel Inheritance"<<endl;
}
};

int main()
{
parent obj1;
child obj2;
grandchild obj3;

obj1.add();
obj2.sum();
obj3.show();
}
Output :

4. Code :

Output :

5. Code :

Output :

You might also like