In the above C++ program to find the area and parameter of a rectangle, we use simple arithmetic operation and calculate the result using the formula.
#include <iostream>
using namespace std;
int main()
{
int width, length, area, perimeter;
cout << "\n\n Find the Area and Perimeter of a Rectangle :\n";
cout << "-------------------------------------------------\n";
cout<<" Input the length of the rectangle : ";
cin>>length;
cout<<" Input the width of the rectangle : ";
cin>>width;
area=(length*width);
perimeter=2*(length+width);
cout<<" The area of the rectangle is : "<< area << endl;
cout<<" The perimeter of the rectangle is : "<< perimeter << endl;
cout << endl;
return 0;
}
Sample Output: Input the length of the rectangle : 23 Input the width of the rectangle : 45 The area of the rectangle is : 1035 The perimeter of the rectangle is : 136