Instructions
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.
If the triangle is a right triangle, output It is a right angled triangle
If the triangle is not a right triangle, output It is not a right angled triangle
the code
#include
#include
using namespace std;
int main()
{
double a,b,c;
cout << "Enter the length of three sides. " << endl;
cin >> a >> b >>c;
if(pow(c,2)-pow(b,2)-pow(a,2) == 0)
cout << "It is a right triangle " << endl;
else if (pow(b,2)-pow(a,2)+pow(c,2) == 0 )
cout << "It's a right triangle" << endl;
else if (pow(c,2) -pow(b,2)+pow(a,2)==0 )
cout << "It's a right triangle" << endl;
else
cout << "It is not a right triangle. " << endl;