Write a program that takes as input from the user three sides of a triangle (numbers), checks and displays
whether the triangle is a right-angled triangle or not.
using namespace std;
/*
Write a program that takes as input from the user three sides of a triangle (numbers), checks and displays
whether the triangle is a right-angled triangle or not.
*/
int main()
{
int a,b,c;
cout<<"\n\tEnter side a: "; cin>>a;
cout<<"\n\tEnter side b: "; cin>>b;
cout<<"\n\tEnter side c: "; cin>>c;
if(a*a+b*b == c*c || b*b+c*c == a*a || c*c+a*a==b*b)
cout<<"\n\tThe triangle with sides a="<<a<<", b="<<b<<" and c="<<c<<" are the sides of a right angle triangle.";
else
cout<<"\n\tThe triangle with sides a="<<a<<", b="<<b<<" and c="<<c<<" are NOT the sides of a right angle triangle.";
return(0);
}
Comments
Leave a comment