Question

Write a C++ program which will prompt as input the value of two sides of a...

Write a C++ program which will prompt as input the value of two sides of a right triangle and then determine the size of the hypotenuse. [Hint: Hypotenuse = square root of (a^2+b^2 ), where a, b are the two sides of a right triangle.]

Homework Answers

Answer #1
#include <iostream>
#include <cmath>

using namespace std;

int main(){
   float a, b, c;
   
   cout<<"Enter size of first side of right triangle: ";
   cin>>a;
   
   cout<<"Enter size of second side of right triangle: ";
   cin>>b;
   
   c = sqrt(a*a+b*b);
   
   cout<<"Size of the hypotenuse = "<<c<<endl;
   
    return 0;
}

Know the answer?
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
Similar Questions
Q.1. Write a program that accepts the lengths of three sides of a triangle as inputs....
Q.1. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is an equilateral triangle. Q.2. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum of the...
Meant to be written in Java JDK 14.0 Three double variables a, b, and c represent...
Meant to be written in Java JDK 14.0 Three double variables a, b, and c represent the length of 3 sides of a triangle. Write a program to determine if the triangle is right triangle. Find the hypotenuse side first.
​​​​​​WRITE FLOWCHART AND PSEUDOCODE ONLY (C++) Write the flowchart and pseudocode for the following program (but...
​​​​​​WRITE FLOWCHART AND PSEUDOCODE ONLY (C++) Write the flowchart and pseudocode for the following program (but not the program itself.) 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. ( sidea2 = sideb2 + sidec2 / sideb2 = sidea2 + sidec2 / …..) The program will read three side lengths from a text file, and then print the lengths along with...
(Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether...
(Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether they are the sides of a right-angled triangle. The function should take three integer arguments and return 1 (true) if the arguments comprise a right-angled triangle, and 0 (false) otherwise. Use this function in a program that inputs a series of sets of integers. Hint: a^2+b^2=C^2 in c programming
write a C program that declares an integer variable called "favorite_number". The program should then prompt...
write a C program that declares an integer variable called "favorite_number". The program should then prompt the user to enter their favorite number, and use scanf to read the user's input into favorite_number. Finally, the program should print a message that includes the user's input.
If the hypotenuse of a right traingle is 5 inches long and one of the sides...
If the hypotenuse of a right traingle is 5 inches long and one of the sides is 4 inches long, how long is the remaining side? a) 2 inches b) 3 inches c) 4 inches d) 5 inches If (a + 1)(a-1) = 3, then a^2 = a. Square root of 2 b. Square root of 3 c. 4 d. 9
In C++ write a program for a multiplication table It must Prompt the user for two...
In C++ write a program for a multiplication table It must Prompt the user for two integers between 1 and 20 (inclusive) • also must Calculates and displays the multiplication table in a well-formatted output The table must include a label for each row and column The program must follow the requirements: • Validates user input, displaying an error message and prompting to user to enter another integer if the input is invalid, and repeating it as many times as...
Convert your algorithm into a C++ program. Your program should output the value of the longest...
Convert your algorithm into a C++ program. Your program should output the value of the longest side of the right-angled triangle. Note, to answer the question, you will need to be able to do square root. To do square root, follow these 2 steps. 1) include the cmath library that allows square root using the statement #include <cmath> 2) To perform a square root, use the syntax sqrt(a double variable or number goes in here); For example cout << sqrt(25.0);   ...
Write a program that will prompt a user to input coordinates for all the corners and...
Write a program that will prompt a user to input coordinates for all the corners and AutoCAD will draw a quadrilateral automatically with your program. The program should draw the quadrilateral on AutoCAD screen and print out all the coordinates with x and y coordinates only. Use GETPOINT, CAR, and CADR for writing the following program. Make sure this program will work with any coordinates that a user may input. None of the numerical coordinates should be in the programming...
Write a basic c++ program to check whether a triangle is valid or not if the...
Write a basic c++ program to check whether a triangle is valid or not if the three sides are given: A triangle is valid if the sum of its two sides is greater than the third side. Let’s say that a, b, c is the sides of the triangle. A valid triangle must satisfy all these conditions: a + b > c a + c > b b + c > a (2 points) Generate random numbers 1-15 inclusive for...