104k views
4 votes
Write in program to find perimeter of rectangle.​

User Jhyap
by
8.4k points

2 Answers

7 votes

Answer:

Step-by-step explanation:

alaminru2020

Ambitious

74 answers

617 people helped

Answer:

Since you did not mention any programming languages, I use C++.

Step-by-step explanation:

#include <iostream>

using namespace std;

double calculate_perimeter(double length, double width) {

double perimeter = 2 * (length + width);

return perimeter;

}

int main() {

double length, width;

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

cin >> length;

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

cin >> width;

double perimeter = calculate_perimeter(length, width);

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

return 0;

}

User Srinath
by
8.2k points
6 votes

Answer:

Since you did not mention any programming languages, I use C++.

Step-by-step explanation:

#include <iostream>

using namespace std;

double calculate_perimeter(double length, double width) {

double perimeter = 2 * (length + width);

return perimeter;

}

int main() {

double length, width;

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

cin >> length;

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

cin >> width;

double perimeter = calculate_perimeter(length, width);

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

return 0;

}

User Nmc
by
8.2k points

No related questions found