Problem 60855. What kind of triangle?
Write a function named check_triangle that receives three positive integers as input: a, b, and c.
These three numbers are intended to represent the sides of a triangle.
The function should return in the variable t one of the following four strings:
a. Not a triangle – The numbers cannot represent the sides of a triangle because they do not satisfy the triangle inequality rule: the sum of any two sides must be greater than the third side.
(Example: the triple 2, 3, 20 does not satisfy the rule because 2 + 3 is not greater than 20.)
b. Equilateral – The numbers represent the sides of an equilateral triangle (example: 4, 4, 4).
c. Isosceles – The numbers represent the sides of an isosceles triangle (example: 5, 5, 4).
d. Scalene – The numbers represent the sides of a scalene triangle (a triangle that is neither equilateral nor isosceles) (example: 4, 8, 5).
Hint: use the if ... else if ... structure.
Assume that the input always consists of three positive integers (greater than zero).
Important:
You must return only the most accurate conclusion regarding the triple a, b, c.
For example, if the triangle is equilateral, return only the corresponding string "Equilateral" and not "Isosceles"or "Scalene".
Terms:
Equilateral – all three sides are equal
Isosceles – two sides are equal
Scalene – all sides are different
Not a triangle – the numbers cannot form a triangle
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers64
Suggested Problems
-
64 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!