# function problem

• 12-03-2008
alyeska
function problem
Hi,
What is wrong with this function?

Code:

```float distance3(float 1px, float 1py, float 1pz, float 2px, float 2py,             float 2pz) {         float dist = 0.0f;         float dist = sqrt(((2px - 1px)(2px - 1px)) + ((2py - 1py)(2py - 1py)) +                  ((2pz - 1pz)(2pz - 1pz)));         return dist; }```
Error is:
Quote:

error C2064: term does not evaluate to a function taking 1 arguments
Any help will be great. Thanks!
• 12-03-2008
laserlight
Did you #include <cmath> for sqrt()?
• 12-03-2008
rags_to_riches
Doesn't
Code:

`((2px - 1px)(2px - 1px))`
need to be
Code:

`((2px - 1px)*(2px - 1px))`
?
• 12-03-2008
laserlight
hmm... yeah, I think rags_to_riches' diagnosis is more accurate.
• 12-03-2008
alyeska
Quote:

Did you #include <cmath> for sqrt()?
Yes, I did..

Quote:

Doesn't

Code:
((2px - 1px)(2px - 1px))need to be

Code:
((2px - 1px)*(2px - 1px))?
Thanks guys, I think that solved the problem..
• 12-03-2008
matsp
Code:

`        float dist = 0.0f;`
Wouldn't that be a tad redundant when you declare another variable by the same name another line below?

--
Mats
• 12-03-2008
alyeska
Quote:

Wouldn't that be a tad redundant when you declare another variable by the same name another line below?

Yes, I actually edited it. Thanks, matsp.

Code:

```float distance3(float 1px, float 1py, float 1pz, float 2px, float 2py,             float 2pz) {         return sqrt(((2px - 1px)(2px - 1px)) + ((2py - 1py)(2py - 1py)) +                  ((2pz - 1pz)(2pz - 1pz))); }```
• 12-04-2008
CornedBee
What is "2px" even supposed to be? Variable names can't start with numbers.