Example 13: Determine the Type of a Triangle
Learn how to identify the type of a given triangle.
We'll cover the following
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.
Get hands-on with 1400+ tech skills courses.