Ask Question
27 February, 05:18

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.

+5
Answers (1)
  1. 27 February, 09:16
    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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers