18.1k views
2 votes
Write a cpp program to calculate area and perimeter of rectangle sv joshi

User Haugholt
by
8.4k points

1 Answer

7 votes

#include <iostream>

using namespace std;

int main()

{

double length, width, area, perimeter;

cout << "Enter the length of the rectangle: ";

cin >> length;

cout << "Enter the width of the rectangle: ";

cin >> width;

// Calculate the area and perimeter

area = length * width;

perimeter = 2 * (length + width);

// Display the results

cout << "Area of the rectangle is: " << area << endl;

cout << "Perimeter of the rectangle is: " << perimeter << endl;

return 0;

}

User Nick Res
by
8.5k points