I don’t see anything immediately wrong with your code. Are you certain that your input is correct?

No offense to The Wolf, but using a different variable shouldn’t make any difference in this situation.

I just compiled and ran the code below, with the output indicated. The only change I made was to your struct definition (I think the change was insignificant). Looks fine to me.

#include <math.h>

#include <iostream.h>

#define NC_PI 3.1415926

struct VECTOR{

float x,y;

};

float Get_Angle_Between_Points(int X1, int Y1, int X2, int Y2);

float dot_product(VECTOR _V1, VECTOR _V2);

float vector_length(VECTOR _V1);

float Get_Angle_Between_Points(int X1, int Y1, int X2, int Y2)

{

float vf_dot_product, vf_length_V1, vf_length_V2, angle;

```
VECTOR V1, V2;
V1.x = X1;
V1.y = Y1;
V2.x = X2;
V2.y = Y2;
vf_dot_product = dot_product(V1, V2);
vf_length_V1 = vector_length(V1);
vf_length_V2 = vector_length(V2);
angle = acos((vf_dot_product/(vf_length_V1*vf_length_V2)));
// Convert the angle to degress
angle = angle * (180/NC_PI);
return angle;
```

}

float dot_product(VECTOR _V1, VECTOR _V2)

{

float dot_product;

dot_product = (_V1.x * _V2.x) + (_V1.y * _V2.y);

return dot_product;

}

float vector_length(VECTOR _V1)

{

float vector_length;

vector_length = sqrt(((_V1.x * _V1.x) + (_V1.y * _V1.y)));

return vector_length;

}

void main(){

```
cout << "angle: " << Get_Angle_Between_Points(0,1,1,0) << endl;
cout << "angle: " << Get_Angle_Between_Points(0,1,1,1) << endl;
cout << "angle: " << Get_Angle_Between_Points(0,1,8,1) << endl;
cout << "angle: " << Get_Angle_Between_Points(1,1,1,1) << endl;
```

}

output:

angle: 90

angle: 45

angle: 82.875

angle: -1.#IND