Ask Question
15 April, 02:22

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. Assume the user does not know the hypotenuse. You may NOT ask the user for the hypotenuse. Meaning, you have to check all 3 sides to verify that it is a right-angled triangle.

+1
Answers (1)
  1. 15 April, 02:35
    0
    C+ + code is explained below

    Explanation:

    /Remove the following line

    //if not using visual studio.

    #include "stdafx. h"

    //Import the required header files.

    #include

    using namespace std;

    //Define the main function.

    int main (void)

    {

    //Define the variables.

    double side1, side2, side3;

    //Prompt the user to enter the sides of the triangle.

    cout << "Enter the side of the triangle:" << endl;

    cout << "Enter first side of triangle:" << endl;

    cin >> side1;

    cout << "Enter second side of triangle:" << endl;

    cin >> side2;

    cout << "Enter third side of triangle:" << endl;

    cin >> side3;

    cout << endl;

    //Check if the triangle sides are valid

    if ((side1 + side2 > side3) &&

    (side1 + side3 > side2) &&

    (side2 + side3 > side1))

    else

    //Display not the valid side.

    cout << "Not a valid side." << endl;

    //Remove the following line if

    //not using visual studio.

    system ("pause");

    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers