c 136 Gentle exercise 91 Using the Pythagorean Theorem calcu

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++

Solution

#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;
}

c++ 13.6 \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site