Question: Modify the program pr3-29.cpp from pages 133, 134 such that it will compute and display at the end the area for the right triangle (hint:
Modify the program pr3-29.cpp from pages 133, 134 such that it will compute and display at the end the area for the right triangle (hint: the area is half the area of the rectangle having the same two sides a, b). You should keep the original code layout and comments and just add your extra statements. Do not delete any of the original statements.
Program 3-29
1 // This program inputs the lengths of the two sides of a right 2 // triangle, then calculates and displays the length of the hypotenuse. 3 #include
5 using namespace std; 6 7 int main() 8 { 9 double a, b, c; 10 11 // Get the length of the two sides 12 cout << "Enter the length of side a: "; 13 cin >> a; 14 cout << "Enter the length of side b: "; 15 cin >> b; 16 17 // Compute and display the length of the hypotenuse 18 c = sqrt(pow(a, 2.0) + pow(b, 2.0)); 19 20 cout << "The length of the hypotenuse is "; 21 cout << c << endl; 22 return 0; 23 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
