61.8k views
5 votes
Write an algorithm to find the perimeter of rectangle








1 Answer

4 votes

Final answer:

An algorithm to find the perimeter of rectangle is:

1) Define the width of the rectangle.

2) Define the Height of the rectangle.

3) Define perimeter of the rectangle.

4) Calculate the perimeter of the rectangle by applying the formula P = 2l + 2w.

5) Assign the perimeter of the rectangle to the area variable.

6) Print the perimeter of the rectangle.

Step-by-step explanation:

The formula for the perimeter (P) is P = 2l + 2w, where ‘l’ is the length and ‘w’ is the width of the rectangle.

An algorithm to find the perimeter of rectangle is:

1) Define the width of the rectangle.

2) Define the Height of the rectangle.

3) Define perimeter of the rectangle.

4) Calculate the perimeter of the rectangle by applying the formula P = 2l + 2w.

5) Assign the perimeter of the rectangle to the area variable.

6) Print the perimeter of the rectangle.

For example: Below is the step by step descriptive logic to find perimeter of a rectangle in 'C' language:

  • Input length and width of the rectangle using scanf() function.
  • Store it in two variables say length and width.
  • Calculate perimeter using formula for perimeter of rectangle perimeter = 2 * (length + width).
  • Print the value of perimeter.
User Reza Del
by
7.7k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.