27/01/2023

C++ Program To Find Triangle Is Equilateral Isosceles Right angled Or Scalene

 Write A C++ Program To Find Triangle Is Equilateral, Isosceles, Right angled Or Scalene. Before writing the code we must know what is Equilateral or what is Isosceles, what is Right angled what is Scalene Triangle. As we all know that triangles have 3 sides. So based on the sides we can identify the type of triangle.

c++ program to check whether the triangle is an equilateral, isosceles or scalene triangle using if else statement

Type of Triangles 


Below are the 4 types of triangles. 

1. Equilateral Triangle


An equilateral triangle is a triangle in which all three sides have the same length. In the familiar Euclidean geometry, an equilateral triangle is also equiangular; that is, all three internal angles are also congruent to each other and are each 60°.

Equilateral Triangle

If all the side (A, B, C) of the Triangle is equal means if A = B = C then the triangle is Equilateral Triangle.

2. Isosceles Triangle


An isosceles triangle is a triangle that has two sides of equal length. Sometimes it is specified as having exactly two sides of equal length, and sometimes as having at least two sides of equal length, the latter version thus including the equilateral triangle as a special case.

Isosceles Triangle

If two sides of a Triangle Is Equal In length means if A = B or B = C or C = A then the triangle is Isosceles Triangle.

3. Right-Angled Triangle


Right-angled triangles are those triangles in which one angle is 90 degrees. Since one angle is 90°, the sum of the other two angles will be 90°.

Right Angled Triangle

To be a right angle means a*a == b*b + c*c or b*b == c*c + a*a or c*c == a*a + b*b any one of the Conditions is true then it is Right angled Triangle.

4. Scalene Triangle


A scalene triangle can be defined as a triangle whose all three sides have different lengths, and all three angles are of different measures. The angles of a scalene triangle follow the angle sum property and always add up to 180.

Scalene Triangle

If all Sides are Unequal Then It is Scalene Triangle.

C++ Program to Check Triangle Is Right-Angled, Equilateral, Isosceles or Scalene


#include<iostream>
using namespace std;
int main()
{
 int a,b,c;

/* Enter all side's Triangle*/
 cout<<"Enter The Value of a, b, c \n";
 cin>>a>>b>>c;

 if(a==b && b==c && c==a)
 {
  cout<<"The Triangle is Equilateral Triangle\n");
 }
 else if(a==b || b==c || c==a)
 {
  cout<<"The Triangle is Isosceles Triangle\n");
 }
 else if(a*a==b*b+c*c ||b*b==c*c+a*a || c*c==a*a+b*b)
 {
  cout<<"The Triangle is Right Triangle\n");
 }
 else
 {
  cout<<"The Triangle Scalene Triangle\n");
 }
 return 0;

}

Triangle Is Equilateral Isosceles Right angled Or Scalene Program Output in C++


Write C++ Program to Check Whether a Triangle Is Right-Angled, Equilateral, Isosceles or Scalene
Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: