Question

c++ The length of the hypotenuse of a right-angled triangle is the square root of the...

c++

The length of the hypotenuse of a right-angled triangle is the square root of the sum of the squares of the other two sides. Write a function calcH that accept two doubles as function arguments and returns a double. Prompt the user for the length of base and the perpendicular side of the triangle. Use the pow and sqrt functions from cmath to perform the calculations

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Any queries comment below
Thank You!!!!

C++ Code:

#include <iostream>
#include <cmath> // importing libaray for mathematical operations
using namespace std;
//function for calculating the Hypothesis
double calH(double base,double per_side)
{
double H;
H = sqrt(pow(base,2)+pow(per_side,2)); // Hypothesis formula
return H; //returning the result
  
}

int main()
{
double b,p_side;
// reading inputs from user
cout<<"Enter Base Side Length: ";
cin>>b;
cout<<"Enter Perpendicular side: ";
cin>>p_side;
//calling function and displaying the result
cout<<"Hypothesis Is "<<calH(b,p_side)<<endl;

return 0;
}

Add a comment
Know the answer?
Add Answer to:
c++ The length of the hypotenuse of a right-angled triangle is the square root of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In a right triangle, the square of the length of one side is equal to the...

    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. If the triangle is a right triangle, output It is a right-angled triangle If the triangle is not a right triangle, output...

  • In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the...

    In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the instructions for starting C++ and viewing the ModifyThis13.cpp file, which is contained in either the Cpp8/Chap09/ModifyThis13 Project folder or the Cpp8/Chap09 folder. Remove both calculation tasks from the main function, and assign both to a program-defined value-returning function named getHypotenuse. Test the program appropriately. //Hypotenuse.cpp - displays the length of a right //triangle's hypotenuse #include <iostream> #include <iomanip> #include <cmath> using namespace std; int...

  • //////// ONLY JAVA **** //////// ONLY JAVA **** 5. In a right triangle, the square of...

    //////// ONLY JAVA **** //////// ONLY JAVA **** 5. 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. (Have the user enter the lengths 3, 4, and 5).

  • In entry level form Develop a C# console application that computes the hypotenuse of a right...

    In entry level form Develop a C# console application that computes the hypotenuse of a right triangle. The computation of the hypotenuse of a right triangle is based on the Pythagorean Theorem: c2 = a2 + b2 and the hypotenuse, c ("long side") of the triangle can be computed with the formula the hypotenuse is equal to the square root of the side a squared plus side b squared. The application should take as many side pairs inputs as the...

  • 1 // This program will input the value of two sides of a right triangle and...

    1 // This program will input the value of two sides of a right triangle and then 2 // determine the size of the hypotenuse. 3 4 // PLACE YOUR NAME HERE 5 6 #include <iostream> 7 #include <cmath> Il needed for math functions like sqrt() 8 using namespace std; 9 10 int main() 11 { 12 float a, b; // the smaller two sides of the triangle 13 float hyp; // the hypotenuse calculated by the program 14 15...

  • Write a JavaScript function called getHypotenuse that returns the length of the hypotenuse of a right...

    Write a JavaScript function called getHypotenuse that returns the length of the hypotenuse of a right triangle given the length of the other two sides. You can utilize the Pythagorean Theorem. Test your function with the following data. getHypotenuse(3, 4) should return 5 getHypotenuse(6, 8) should return 10 Rewrite the above function as an arrow function.

  • This question is from the textbook "Python for ArcGIS" by Laura Tateosian: Write a script "triangles.py"...

    This question is from the textbook "Python for ArcGIS" by Laura Tateosian: Write a script "triangles.py" that takes three arguments, the lengths of three sides of a triangle. Then define the following three functions: 1. perimeter takes three side lengths as arguments and returns the perimeter length. 2. triangleType takes three side lengths as arguments, determines if it is an equilateral triangle, an isosceles triangle, or neither. The result is returned. 3. area takes three side lengths as arguments and...

  • Python Programming 4th Edition Write a program that calculates the length of a right triangle's hypotenuse....

    Python Programming 4th Edition Write a program that calculates the length of a right triangle's hypotenuse. Hints: Define main() program Get the length of the triangle’s two sides (user input) Call math function to calculate the length of the hypotenuse. The output should look like as follows: The length of the hypotenuse is 12.041594578792296

  • 1 wite single statement that assigns avg,sales with the average of num, salest, num,sales. and num_sales3....

    1 wite single statement that assigns avg,sales with the average of num, salest, num,sales. and num_sales3. Write a program that computes even numbers from 1 to 100 2. The mathematical definition of a right angle triangle is the sum of the squares of the other two sides. Write a side of a triangle, if the length of the other two sides are hypotenuse equals that the square of the python code to calculate the hypotenuse A-

  • (JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore,...

    (JAVA) Implement a Triangle class. Any triangle can be represented by its THREE sides. Therefore, your class will have THREE private member variables → side1, side2 and side3. Use the double data type to represent the triangle sides. In addition, please provide public methods that perform the following FIVE tasks: ▪ An input method that obtains the appropriate values for the three sides from the user. While entering the values of the three sides, please remember the triangle property that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT