Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

________________________________

Write a program to define a class named rectangle with following


requirements:
1. Private members/functions : length and breadth
2. Public members/functions : inputdimension() for inputting
values of length and breadth, area() for calculating the area of
rectangle.



#include<iostream.h>
#include<conio.h>

class rectangle
{
float length;
float breadth;
float area()
{
cout<<"The area of the given Rectangle is:
<<length*breadth;
return 0;
}


public:
void inputdimension()
{
cout<<"Enter the length of rectangle:";
cin>>length;
cout<<"Enter the breadth of the rectangle:";
cin>>breadth;
}


} case1;


void main()
{
clrscr();

case1.inputdimension();
case1.area();
getch();
}



Output:
Enter the length of rectangle: 80
Enter the breadth of rectangle: 60
The area of the given rectangle is: 4800

You might also like