Respuesta :
Answer:
The programming language is not stated;
I'll answer using C++
#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
if(side1<=0 || side2 <= 0 || side3 <= 0) {
cout<<"Invalid Inputs";
}
If otherwise
else {
The following if condition assumes that side1 is the largest and test using Pythagoras Theorem
if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) {
cout<<"Right Angled";
}
The following if condition assumes that side2 is the largest and test using Pythagoras Theorem
else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) {
cout<<"Right Angled";
}
The following if condition assumes that side3 is the largest and test using Pythagoras Theorem
else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) {
cout<<"Right Angled";
}
If none of the above conditions is true, then the triangle is not a right angles triangle
else {
cout<<"Not Right Angled";
}
}
return 0;