distance between center of circles

closed account (1vf9z8AR)
Why is my output wrong?

1
2
3
cin>>x1>>y1>>r1>>x2>>y2>>r2;
        int dist=(sqrt(pow((x1-x2),2)+pow((y1-y2),2)));
        cout<<dist;
int can only store whole numbers. You probably want to store the result as a double instead.
Last edited on
closed account (1vf9z8AR)
but even when I input 100 in x1, y1, x2, and y2 I don't get 0 as my answer.
What is the type of x1, x2, etc. ?
closed account (1vf9z8AR)
float
closed account (1vf9z8AR)
Ok, I figured it out. No problem with the calculation rather another part of my program messing with the "dist" variable.
Topic archived. No new replies allowed.