For some reason when I compile my code the hypotenuse returns to just 0 and it returns an integer and not a double and was wanting to know if anyone had any suggestions........

#include <iostream>
#include <cmath>
using namespace std;
double Calculate_Hypotenuse(int length_one, int length_two);

int main()
{
	int length_one, length_two;
	double hypotenuse = 0.0;

	cout << "Programmed by Jim Johnson";
	cout << endl << endl << "Type a negative number for side 1 to exit the program";
	cout << endl;

	do
	{

	cout << "Enter the length of the side 1 in inches: ";
	cin >> length_one;

	if (length_one >= 0)
	{

	cout << "Enter the length of the side 2 in inches: ";
	cin >> length_two;

	cout << endl << endl << "Triangle: Side 1: " << length_one << " inches";
	cout << endl <<"\t  Side 2: " << length_two << " inches";

	Calculate_Hypotenuse(length_one, length_two);
	cout << endl <<"Hypotenuse: " << hypotenuse << " inches";
	cout << endl << endl;
	
	}
	
	
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(2);

	
	} while (length_one >=0);
	return 0;
}

	double Calculate_Hypotenuse(int length_one, int length_two)
	{
		double area;
		double hypotenuse;

		area = pow(length_one,2.0) + pow(length_two,2.0);
		hypotenuse = sqrt(area);
		

			return hypotenuse;
	}
// ...
  if (length_one >= 0)
  {

  cout << "Enter the length of the side 2 in inches: ";
  cin >> length_two;

  cout << endl << endl << "Triangle: Side 1: " << length_one << " inches";
  cout << endl <<"\t  Side 2: " << length_two << " inches";

  hypotenuse = Calculate_Hypotenuse(length_one, length_two);
  cout << endl <<"Hypotenuse: " << hypotenuse << " inches";
  cout << endl << endl;

  }
  // ...

I believe you need to cast the integers to doubles to return a double.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.