Write a program that prompt the user for the lengths in inch

Write a program that prompt the user for the lengths in inches of two legs of a right triangle and make use of the pow and the sqrt functions and the Pythagorean theorem to compute the length of the hypotenuse.

Solution

Pythagores Theorem States that

Hypotenuse = sqrt( Base^2 + Height ^2)

Code:


#include<cmath>
#include<iostream>
using namespace std;
int main()
{
   float base,height;
   float hypo;
   cout<<\"Enter two sides of traingle: \";
   cin>>base>>height;
   hypo=sqrt(pow(base,2) + pow(height,2));
   cout<<\"\ Hypotenuse is \"<<hypo;
   return 0;
}

Write a program that prompt the user for the lengths in inches of two legs of a right triangle and make use of the pow and the sqrt functions and the Pythagorea

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site