0% found this document useful (0 votes)
5 views

12 PP

Uploaded by

shambhupawar293
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

12 PP

Uploaded by

shambhupawar293
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sr.

no:05

Practical Related Question.

1.Write a C++ program to calculate the area and perimeter of rectangles using concept of
inheritance.
#include<iostream.h>

#include<conio.h>

class Area

public:

float area(float l,float b)

return l*b;

};

class Perimeter

public:

float perimeter(float l,float b)

return 2*(l+b);

};

class Rectangle:public Area,public Perimeter

float length,breadth;

public:

void get_data()

cout<<"\nEnter length:";

cin>>length;

cout<<"\nEnter breadth:";

cin>>breadth;

}
Sr.no:05

void put_data()

cout<<"\nArea:"<<area(length,breadth);

cout<<"\nPerimeter:"<<perimeter(length,breadth);

};

void main()

Rectangle r;

r.get_data();

r.put_data();

return 0;

Output:

You might also like