cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How can I fix this?
How can I fix this?
Dec 14, 2016 at 9:34pm UTC
leocc
(2)
There is an error in my code, this is what it looks like (just the part where the error is). How can I fix it?
d=sqrt((x2-x1)^2+(y2-y1)^2);
Dec 14, 2016 at 9:45pm UTC
AbstractionAnon
(6954)
What is the error?" Do you think we are mind readers?
What are the types of d, x1, x2, y1, y2?
^2
is not an exponentiation operator. ^ is the bitwise XOR operator.
Dec 14, 2016 at 9:45pm UTC
joe864864
(249)
You are taking the square root correctly but your not squareing your numbers correctly you need to us pow. So
(x2-x1)^2
should look like
pow((x2-x1),2)
http://www.cplusplus.com/reference/cmath/pow/
Dec 14, 2016 at 10:22pm UTC
leocc
(2)
Thanks a lot guys.
Topic archived. No new replies allowed.