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.
Answer: #include <iostream> using namespace std; int main(){ int a,b,c; cout<<"Input firstside: "; cin>>a; cout<<"Input secondside: "; cin>>b; cout<<"Input thirdside: "; cin>>c; if((a*a+b*b==c*c)||(a*a+c*c==b*b)||(c*c+b*b==a*a)) cout<<"Triangleis right"<<endl; else cout<<"Triangleis not right"<<endl; return 0;} Result:Input first side: 3Input second side: 4Input third side: 5Triangle is right
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!
Learn more about our help with Assignments:
C++