64 763
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #52577 in C++ for Erick

Question #52577
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


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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions