Answer to Question #314222 in C++ for Hoorain Fatima

Question #314222

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.

1
Expert's answer
2022-03-19T02:24:56-0400
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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog