Computer Science, asked by saikiran5760, 9 months ago

How towrite an algorithm to calculate perimeter and surface area of a square

Answers

Answered by thebestfoodof2020
0

Answer:

Here is your answer

Explanation:

Algorithm 1:

Input1 = length of base

Input2 = height

Output (Area) = 0.5 * Input1 * Input2

Algorithm 2: Heron's Formula

Input 1 = side1

Input 2 = side2

Input 3 = side3

Calculate semiperimeter s = (Input1 + Input2 + Input 3) / 2

Output (Area) = sqrt {s * (s - Input1) * (s - Input2) * (s - Input3)}

Algorithm 3: Co-ordinate Geometry

Accept the co- ordinates of the three vertices of the triangle as 6 inputs x1, y1, x2, y2, x3, ye

Apply distance formula to calculate the length of the three sides as:

side1 = sqrt { (x2 - x1) ^ 2 + (y2 - y1) ^ 2}

side2 = sqrt { (x3 - x2) ^ 2 + (y3 - y2) ^ 2}

side3 = sqrt { (x1 - x3) ^ 2 + (y1 - y3) ^ 2}

Once, we have got the lengths of the three sides, apply Algorithm 2.

Enjoy..!

Similar questions