Write an algorithm to find the perimeter of rectangle
Answers
Explanation:
The basic components of an algorithm is Name of the algorithm, Input, Output, Data Structures Used and Steps.
The Name of the algorithm section consists of a name which you want to give.
Let it be “Algo_Peri_Rec()”.
The Input section consists of the list of variable(s) which are used to take input from the user.
In this case we need two inputs from the user : One for Length, let it be “len” and the other is for Breadth, let it be “bre”.
The Output section consists of the list of variable(s) which are to be given as Output (Result) for our Algorithm (Program).
In this case we need only one variable to display the result, Let it be “peri”.
The Data Structure Used section consists of Data Structure Used by our algorithm (program) and their description in a brief way. Examples of Data Structure are “Array”, “Link Lists”, etc.
For our Algorithm of finding perimeter of rectangle we don't need any Data Structures.
The Steps section consists of all the process (lines of pseudocodes) including mathematical or logical ways to get the desired Output from the input, with proper indentation.
I'm summing all the sections and writing an simple Algorithm, you can modify to more accurate form.
________________________________________________________________
Algo_Peri_Rec()
Inputs: len for Length of the Rectangle and bre for Breadth of the Rectangle.
Output: peri for Perimeter of the Rectangle, or suitable unsuccessful message.
Data Structures Used: No Data Structures are used for this Algorithm.
Steps:
Begin
If(len<=0)
Print "Length cannot be Zero or Negative"
Else If(bre<=0)
Print "Breadth cannot be Zero or Negative"
Else
peri = 2 * (len + bre)
End If
End
Answer:
the answer is 2 × (l+b)
Explanation:
it had 4 sides
so l+b = 1 and then mulyiply it by 2...