A program to find the area of rectangle in C++

 

#include<iostream>
using namespace std;
class Rectangle
{
private:
float l,b,a;
public:
void setdata()
{
cout<<“enter length and breadth”;
cin>>l>>b;
}
float getarea()
{
a=l*b;
return(a);
}
};
int main()
{
Rectangle rect1;
rect1.setdata();
float res;
res=rect1.getarea();
cout<<“Area=”<<res;
}

Output:

 

Leave a Reply

Your email address will not be published. Required fields are marked *