107k views
0 votes
Write an algorithm for a program which inputs the lengths a, b and c of the three sides of a triangle. The program then determines whether the triangle is right-angled and prints out a message to say whether or not the triangle is right angled. You may assume that a is the longest side.

User Tam
by
4.4k points

1 Answer

2 votes

Answer:

Algorithm:

Step 1: Start

Step 2: Declare variables a,b,c

Step 3: Input a,b,c

Step 4: If a^2 == b^2 + c^2

Display "The triangle is right angled"

Else

Display "The triangle is not right angled"

Step 5: Stop

Step-by-step explanation:

A triangle is right angled if the square of the largest side equals the sum of the square of the other two sides

The algorithm will be based on the above analysis.

This indicated the start of the algorithm

Step 1: Start

This declares required variables

Step 2: Declare variables a,b,c

This gets values for the declared variables

Step 3: Input a,b,c

This checks for the condition to determine right angled triangle

Step 4: If a^2 == b^2 + c^2

If true, this message that states the triangle is right angled is printed

Display "The triangle is right angled"

If otherwise

Else

This message that states the triangle is not right angled is printed

Display "The triangle is not right angled"

This indicates the end of the algorithm

Step 5: Stop

The algorithm when implemented in Python is as follows:

a = float(input("a: "))

b = float(input("b: "))

c = float(input("c: "))

if a**2 == b**2 + c**2:

print("The triangle is right angled")

else:

print("The triangle is not right angled")

It follows the same explanation as the algorithm

User Peppermintology
by
4.3k points