Saturday, 7 March 2015

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

Problem :- Write A C++ Program To Find Triangle Is Equilateral  Isosceles Scalene Angled.

Logic :-Below i written all the condition see and apply in programming

Equilateral :-

If All The Side's (A,B,C) of Triangle is equal means if A=B=C then triangle is Equilateral.

Isosceles :-

If Two Sides of Triangle Is Equal In length means if A=B or B=C And C=A then triangle is Isosceles.

Right angled :-

Containing or being 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 Condition is true then it is Right angled Triangle.

Scalene :-

If All Side's are Unequal Then It is Scalene Triangle .

Solution :-

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

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

if(a==b && b==c && c==a)
{
cout<<"The Triangle is Equilateral\n");
}
else if(a==b || b==c || c==a)
{
cout<<"The Triangle is Isosceles\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 angled\n");
}
else
{
cout<<"The Triangle Scalene angled\n");
}
return 0;

}

Output:-

C++ Program To Find Triangle Is Equilateral Isosceles Scalene

No comments:
Write comments

Recommended Posts × +