### pythagoream theorem

I am trying to find the hypotenuse of a right triangle with the user entering side a and side b. My program is having a problem in the function where it computes the hypotenuse. I think it might have to do with the sqrt because that's where I get an error and I've tried messing with it to no avail. Everything is right except for the above mentioned part so can you tell or show me how to get it right. Thanks.
 ``123456789101112131415161718192021222324252627282930313233343536373839`` `````` #include #include using namespace std; //function prototype double rightTriangle (double, double ); int main() { double side_a, side_b, hypotenuse; //tells user what program will do cout<<"This program will return the value of the hypotenuse of a right triangle but\n"; cout<<"you will need to enter the values for side a and side b of the right triangle\n"; cout<<"in order to do so."<>side_a; cout<>side_b; cout<
There are a few errors, but the main one is line 31. You should not attempt to define a variable named sqrt. The function sqrt() is already declared in the cmath header file.
Last edited on
In your function you declared three variables, hypotenuse, sqrt, sides. Then you try to use a function named sqrt(), on line 34. The compiler doesn't know if you want to use the variable sqrt or the function sqrt() on line 34. You don't want to declare that variable named sqrt, if you remove that declaration that should clear up the problem with sqrt().

Jim
Last edited on
Thanks. That seemed to clear up my problem but when I try to run the program I get the following:
6_2Num3.obj : error LNK2019: unresolved external symbol "double __cdecl rightTriangle(double,double)" (?rightTriangle@@YANNN@Z) referenced in function _main

and this too:
c:\users\owner\documents\visual studio 2010\Projects\6_2Num3\Debug\6_2Num3.exe : fatal error LNK1120: 1 unresolved externals
Line 29, there's a spelling mistake.
You wrote "rightTriange", without an 'L'.
Thanks, I appreciate all of your help. It's always the small stuff that gets in the way.
Topic archived. No new replies allowed.