wow, that cleared a lot up, but I'm still having probloms with getting the function to work, this is what I've done, but still some questions:
#include <iostream.h>
#include <math.h>
#include <conio.h>
double pyth(double s1, double s2, double in1, double in2, double sqAdd, double product);
int main()
{
double z, in1, in2, product; //I want x and y to be the inputs and assign them to be c and d in the function, if that's legal.
int i;
cout << "This program is to be used to figure out the side of a right triangle using Pythagoran's Theorum. if you want to know the background of pythagoran's theorum, type 3"<<endl;
for (;;)
{
cout << "To find out the length of the hypotenuse, press 1, and to find the length of a leg, press 2, to check to see if a triangle is right, press 3, for help, type 5 and to exit, press 9."<<endl;
cin >>i;
switch (i)
{
case 5:
cout << "basicly Pythags Theorum is used to find the length of the hypotenuse, or leg of a right triangle, and only a right triangle. Incidently, since it;s only used to find out a right triangle, you can use it to find out if the triangle in question is square or not if you have the length of the two sides. The theorum finds out the length of a side using the fromula a^2 + b^3 = c^2(for the hypotenuse), or c^3 - b^2 = a^2. Then after you have the answer, you square root it to get the side. This program does this very fast and easily.\n\n\n"<<endl;
break;
case 9:
return 0;
case 1:
cout << "please enter the length of one leg, then the other.\n";
cin >>in1>>in2;
cout << "the length of the hypotenuse is " <<product<<" and the length of it before being rooted is .\n\n\n";
break;
case 2:
cout << "Please enter the length of one side, then the hypotenuse "<<endl;
cin >>in1>>in2;
cout << "the length of the missing side is " <<product<<", and before being square rooted, is .\n\n\n";
break;
case 3:
cout << "please enter the length of two sides " <<endl;
cin >>in1>>in2;
cout << "\nNow, please enter the length of the hypotenuse ";
cin >>z;
if (z == product)
cout <<"yes, the triangle is a right triangle\n\n\n";
else if (z < product)
cout << "Nope, you've got yourslef an acute triangle\n\n\n";
else if (z > product)
cout << "Nope, you've got yourself an obtuse triangle\n\n\n";
break;
default:
cout <<"please enter a valid entry"<<endl;
}
}
}
double pyth(double s1, double s2, double in1, double in2, double sqAdd, double product)
{
s1 = pow(in1, 2);
s2 = pow(in2, 2);
sqAdd = s1 + s2;
product = sqrt(sqAdd);
return product;
}
did anyone notice anything I did wrong? the program compiles, but the problom is it doesn't return the right value.
thanks again for the help.