Bootcamps
Masterclasses
Menu
Courses
Account
Login / Sign Up

Classify a Triangle Using Sides and Angles

Basic Acceptance 73.99% Points 10

You are given three sides of a valid triangle. Your task is to classify the triangle both by its sides and by its angles.

Classify the triangle by sides as Equilateral, Isosceles, or Scalene, based on the equality of its sides.

Classify the triangle by angles as Right, Acute, or Obtuse, using the relationship between the squares of the sides. Let the largest side be (c), and the other two sides be (a) and (b).

  • If (a2 + b2 = c^2), the triangle is Right.
  • If (a2 + b2 > c^2), the triangle is Acute.
  • If (a2 + b2 < c^2), the triangle is Obtuse.
Examples
Example 1

image Input: a = 3, b = 4, c = 5
Output: Scalene, Right
Explanation: No sides are equal, and 3² + 4² = 5², forming a right triangle.

Example 2

image Input: a = 5, b = 5, c = 5
Output: Equilateral, Acute
Explanation: All sides are equal, and every angle is 60°, making the triangle acute.

Example 3

image Input: a = 5, b = 5, c = 9
Output: Isosceles, Obtuse
Explanation: Two sides are equal, and 9² > 5² + 5², so the triangle is obtuse.

Constraints
  • 0 < each side <= 104
  • The sides form a valid triangle.
Topics
Data Structures Basics Comparisons
Companies
Amazon Apple
Added 31 Oct 2026 73.99% acceptance
Ln 1, Col 1Sign in to save your code
3 4 5
Scalene, Right