Example 13: Determine the Type of a Triangle

Learn how to identify the type of a given triangle.

Problem

Write a program that takes three sides of a triangle as input, and checks whether the triangle is isosceles, equilateral, scalene, or right-angled.

The output should be printed on the console in the following manner:

  • Scalene triangle
  • Isosceles triangle
  • Equilateral triangle
  • Right-angled triangle
  • The sides do not form a triangle

Example

Input Output
6, 8, 10 Scalene triangle; Right-angled triangle
3, 3, 3 Equilateral triangle
5, 3, 12 The sides do not form a triangle

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.