asked 116k views
0 votes
Write an algorithm to input three sides of a triangle and print if it is scalene, isosceles, or equilateral.

1 Answer

5 votes

Final answer:

To determine if a triangle is scalene, isosceles, or equilateral, compare the lengths of its sides. Use conditions for each type of triangle: equilateral, isosceles, and scalene. Write a step-by-step algorithm to solve the problem.

Step-by-step explanation:

To determine if a triangle is scalene, isosceles, or equilateral, we can compare the lengths of its sides. First, input the three sides of the triangle. Then, we can use the following conditions:

- If all three sides are equal, it is an equilateral triangle.

- If two sides are equal and one side is different, it is an isosceles triangle.

- If all three sides are different, it is a scalene triangle.

Based on these conditions, we can write a detailed algorithm to solve the problem. Here's a step-by-step explanation:

  1. Input the three sides of the triangle.
  2. Check if all three sides are equal. If yes, print "Equilateral triangle".
  3. Check if exactly two sides are equal. If yes, print "Isosceles triangle".
  4. If none of the above conditions is true, print "Scalene triangle".

Learn more about Triangle Classification

answered
User Simon Peverett
by
8.2k points

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.