Area and Perimeter both are the mathematical terms used with rectangle, area is the length multiplied by width while perimeter is the length of all sides of the rectangle. Now how we can implement area and perimeter of a rectangle in C++, In the below example we did it with the help of classes.
using namespace std;
return 2*(this->Length + this->Width);
this->Width = Width;
this->Length = Length;
return this->Length * this->Width;
In the above code we defined a rectangle class with data members length and width, we have member functions for setwidth() and setlength() which sets the values of length and width, then we have functions for finding area and perimeter for the given length and width, the function area() finds the area by multiplying the length and width, while the function perimeter() returns the perimeter by adding all the sides. In our main() function we created an object of class rectangle, we set the values and then called the functions for area and perimeter.