Answer to Question #244764 in C++ for Fely

Question #244764
Define a function hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. Use this function in a program to determine the length of the hypotenuse for each of the following triangles. The function takes two arguments of type double and return the hypotenuse as a double.
1
Expert's answer
2021-09-30T04:46:07-0400
#include<iostream>
#include<cmath>
using namespace std;
double hypotenuse(double s1, double s2){
	double h = pow(s1, 2) + pow(s2, 2);
	return sqrt(h);
}


int main(){
	cout<<"Hypotenus: "<<hypotenuse(3,4)<<endl;
	cout<<"Hypotenus: "<<hypotenuse(5,12)<<endl;
	cout<<"Hypotenus: "<<hypotenuse(8,15)<<endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS