c++ 13.6 \"Gentle\" exercise 9.1 Using the Pythagorean Theorem, calculate the hy
ID: 3936750 • Letter: C
Question
c++
13.6 "Gentle" exercise 9.1
Using the Pythagorean Theorem, calculate the hypotenuse of a right triangle given the length of the two shorter sides. Be certain to use the square and squareRoot functions from the Gentle Introduction* textbook. (You will need to change the square function to use floating point numbers though.) Ask the user if s/ he wants to keep entering data; if "Yes" then continue prompting and calculating. Assume no sides are negative. Solving this might involve some research on your part! Use the following sample as a guide:
c++
Explanation / Answer
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
float A, B, hypotenuse;
int a=1;
while (a)
{
cout << " enter side A and length should be positive";
cin >> A;
cout << " enter side B and length should be positive";
cin >> B;
hypotenuse = sqrt((A*A)+(B*B));
cout << " The hypotenuse length is: " << (hypotenuse);
cout <<" do you want to continue then input 1";
cin >>a;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.