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.
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 | #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