Answer to Question #263550 in C++ for DANISH

Question #263550

In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.


1
Expert's answer
2021-11-11T07:31:15-0500
#include <iostream>
#include <cmath>
using namespace std;
int main()
{


	double first,second,third;




	cout << "Enter the length of three sides. " << endl;
	cin >> first >> second >>third;
	 if(pow(third,2)-pow(second,2)-pow(first,2) == 0)
		 cout << "The triangle is  a right triangle "  << endl;


	 else if (pow(second,2)-pow(first,2)+pow(third,2) == 0 )
		 cout << "The triangle is a right triangle" << endl;
	 else if (pow(third,2) -pow(second,2)+pow(first,2)==0 )
		 cout << "The triangle is a right triangle" << endl;
	 else
		 cout << "The triangle  is not a right triangle. " << endl;












	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
APPROVED BY CLIENTS