Given three integers as **X**, **Y**, and **Z** representing the three sides of a triangle, the task is to check whether the triangle formed by the given sides is equilateral, isosceles, or scalene.

Equilateral Triangle:A triangle is said to be equilateral triangle if all the sides are equal. If X, Y, Z are three sides of the triangle. Then, the triangle is equilateral only if X = Y = Z.

Isosceles Triangle:A triangle is said to be an isosceles triangle if any of its two sides are equal. If X, Y, Z are three sides of the triangle.Then, the triangle is isosceles if either X = Y or X = Z or Y = Z.

Scalene Triangle:A triangle is said Scalene Triangle if none of its sides is equal.

**Examples:**

Input:X = 6, Y = 8, Z = 10Output:Scalene TriangleExplanation:

Since all the sides of the given triangle are unequal, the triangle is scalene.

Input:X = 10, Y = 10, Z = 10Output:Equilateral TriangleExplanation:

Since all the sides of the given triangle are equal.

**Approach:** Follow the steps below to solve the problem:

- Check if
**X = Y**and**Y = Z**. If found to be true, print “Equilateral Triangle”. - If it is not an Equilateral triangle, then check if
**X = Y**or**X = Z**or**Y = Z**. If found to be true, print “Isosceles Triangle”. - If none of the above steps are satisfied, then print “Scalene Triangle”.

Below is the implementation of the above approach:

## C++

`// C++ program for the above approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to check if the triangle ` `// is equilateral or isosceles or scalene ` `void` `checkTriangle(` `int` `x, ` `int` `y, ` `int` `z) ` `{ ` ` ` ` ` `// Check for equilateral triangle ` ` ` `if` `(x == y && y == z) ` ` ` `cout << ` `"Equilateral Triangle"` `; ` ` ` ` ` `// Check for isoceles triangle ` ` ` `else` `if` `(x == y || y == z || z == x) ` ` ` `cout << ` `"Isoceles Triangle"` `; ` ` ` ` ` `// Otherwise scalene triangle ` ` ` `else` ` ` `cout << ` `"Scalene Triangle"` `; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` ` ` `// Given sides of triangle ` ` ` `int` `x = 8, y = 7, z = 9; ` ` ` ` ` `// Function call ` ` ` `checkTriangle(x, y, z); ` `} ` ` ` `// This code is contributed by jana_sayantan ` |

*chevron_right*

*filter_none*

## Java

`// Java program for the above approach ` `class` `GFG{ ` ` ` `// Function to check if the triangle ` `// is equilateral or isosceles or scalene ` `static` `void` `checkTriangle(` `int` `x, ` `int` `y, ` `int` `z) ` `{ ` ` ` ` ` `// Check for equilateral triangle ` ` ` `if` `(x == y && y == z ) ` ` ` `System.out.println(` `"Equilateral Triangle"` `); ` ` ` ` ` `// Check for isoceles triangle ` ` ` `else` `if` `(x == y || y == z || z == x ) ` ` ` `System.out.println(` `"Isoceles Triangle"` `); ` ` ` ` ` `// Otherwise scalene triangle ` ` ` `else` ` ` `System.out.println(` `"Scalene Triangle"` `); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` ` ` `// Given sides of triangle ` ` ` `int` `x = ` `8` `, y = ` `7` `, z = ` `9` `; ` ` ` ` ` `// Function call ` ` ` `checkTriangle(x, y, z); ` `} ` `} ` ` ` `// This code is contributed by jana_sayantan ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program for the above approach ` ` ` `# Function to check if the triangle ` `# is equilateral or isosceles or scalene ` `def` `checkTriangle(x, y, z): ` ` ` ` ` `# _Check for equilateral triangle ` ` ` `if` `x ` `=` `=` `y ` `=` `=` `z: ` ` ` `print` `(` `"Equilateral Triangle"` `) ` ` ` ` ` `# Check for isoceles triangle ` ` ` `elif` `x ` `=` `=` `y ` `or` `y ` `=` `=` `z ` `or` `z ` `=` `=` `x: ` ` ` `print` `(` `"Isoceles Triangle"` `) ` ` ` ` ` `# Otherwise scalene triangle ` ` ` `else` `: ` ` ` `print` `(` `"Scalene Triangle"` `) ` ` ` ` ` `# Driver Code ` ` ` `# Given sides of triangle ` `x ` `=` `8` `y ` `=` `7` `z ` `=` `9` ` ` `# Function Call ` `checkTriangle(x, y, z) ` |

*chevron_right*

*filter_none*

## C#

`// C# program for the above approach ` `using` `System; ` ` ` `class` `GFG{ ` ` ` `// Function to check if the triangle ` `// is equilateral or isosceles or scalene ` `static` `void` `checkTriangle(` `int` `x, ` `int` `y, ` `int` `z) ` `{ ` ` ` ` ` `// Check for equilateral triangle ` ` ` `if` `(x == y && y == z ) ` ` ` `Console.WriteLine(` `"Equilateral Triangle"` `); ` ` ` ` ` `// Check for isoceles triangle ` ` ` `else` `if` `(x == y || y == z || z == x ) ` ` ` `Console.WriteLine(` `"Isoceles Triangle"` `); ` ` ` ` ` `// Otherwise scalene triangle ` ` ` `else` ` ` `Console.WriteLine(` `"Scalene Triangle"` `); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` ` ` `// Given sides of triangle ` ` ` `int` `x = 8, y = 7, z = 9; ` ` ` ` ` `// Function call ` ` ` `checkTriangle(x, y, z); ` `} ` `} ` ` ` `// This code is contributed by code_hunt` |

*chevron_right*

*filter_none*

**Output:**

Scalene Triangle

**Time Complexity:** O(1)**Auxiliary Space:** O(1)

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Maximum count of Equilateral Triangles that can be formed within given Equilateral Triangle
- Biggest Reuleaux Triangle inscribed within a Square inscribed in an equilateral triangle
- Maximum number of 2x2 squares that can be fit inside a right isosceles triangle
- Maximum number of squares that can fit in a right angle isosceles triangle
- Find the altitude and area of an isosceles triangle
- Divide an isosceles triangle in two parts with ratio of areas as n:m
- Find two vertices of an isosceles triangle in which there is rectangle with opposite corners (0, 0) and (X, Y)
- Program to calculate area and perimeter of equilateral triangle
- Program to calculate area of Circumcircle of an Equilateral Triangle
- Program to calculate the Area and Perimeter of Incircle of an Equilateral Triangle
- Time required to meet in equilateral triangle
- Biggest Square that can be inscribed within an Equilateral triangle
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Area of circle which is inscribed in equilateral triangle
- Largest hexagon that can be inscribed within an equilateral triangle
- Largest square that can be inscribed within a hexagon which is inscribed within an equilateral triangle
- Count of distinct rectangles inscribed in an equilateral triangle
- Area of Equilateral triangle inscribed in a Circle of radius R
- Maximum area of rectangle inscribed in an equilateral triangle
- Area of Circumcircle of an Equilateral Triangle using Median

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.