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.

Expert's answer

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: 3 Input second side: 4 Input third side: 5 Triangle is right

## Comments

## Leave a comment