Answer:
<em>The programming language is not stated;</em>
<em>I'll answer using C++</em>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int side1, side2, side3;
cout<<"Enter the three sides of the triangle: "<<endl;
cin>>side1>>side2>>side3;
if(side1<=0 || side2 <= 0 || side3 <= 0)
{
cout<<"Invalid Inputs";
}
else
{
if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001)
{
cout<<"Right Angled";
}
else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001)
{
cout<<"Right Angled";
}
else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001)
{
cout<<"Right Angled";
}
else
{
cout<<"Not Right Angled";
}
}
return 0;
}
Explanation:
The following line declares the three variables
int side1, side2, side3;
The next line prompts user for input of the three sides
cout<<"Enter the three sides of the triangle: "<<endl;
The next line gets user input
cin>>side1>>side2>>side3;
The following if condition checks if any of user input is negative or 0
<em> if(side1<=0 || side2 <= 0 || side3 <= 0)
{
</em>
<em> cout<<"Invalid Inputs";
</em>
<em> }
</em>
If otherwise
else
{
The following if condition assumes that side1 is the largest and test using Pythagoras Theorem
<em>if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001)
{
</em>
<em> cout<<"Right Angled";
</em>
<em> }
</em>
The following if condition assumes that side2 is the largest and test using Pythagoras Theorem
<em> else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001)
{
</em>
<em> cout<<"Right Angled";
</em>
<em> }
</em>
The following if condition assumes that side3 is the largest and test using Pythagoras Theorem
<em> else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001)
{
</em>
<em> cout<<"Right Angled";
</em>
<em> }
</em>
If none of the above conditions is true, then the triangle is not a right angles triangle
<em> else
{
</em>
<em> cout<<"Not Right Angled";
</em>
<em> }
</em>
}
return 0;