170,251 views
19 votes
Write a program in c++ that calculate the area and perimeter of a rectangle

User DoctorAV
by
3.6k points

1 Answer

10 votes

Answer:

c++

Step-by-step explanation:

using namespace std;

class areaPerimeter

{

private:

float len;

public:

void getData();

float findArea();

float findPerimeter();

};

void CodesCracker::getData()

{

cout<<"Enter the Length of Square: ";

cin>>len;

}

float CodesCracker::findArea()

{

return (len*len);

}

float CodesCracker::findPerimeter()

{

return (4*len);

}

int main()

{

CodesCracker c;

float area, per;

c.getData();

area = c.findArea();

per = c.findPerimeter();

cout<<"\\Area = "<<area;

cout<<"\\Perimeter = "<<per;

cout<<endl;

return 0;

}

User Kolergy
by
3.8k points