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:-
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;
}
Thanks a lot your programming code is neat and clean, and I mostly like the way of explanation of the program. I have also gone through Hacker Rank Programming Solutions are also great for learning and implementing the logic. Thanks again and Keep it up.
ReplyDelete