0

Trying to write a program that will add two vectors (of type vect_t) and return a vector of type vect_t. Though I can't get my add_vect function to work. lots of redefinition errors telling me different basic types, and i can't figure out how to make it work right. Any insight would be extremely helpful. Thanks

```
typedef struct {
double r;
double theta;
} vect_t;
double x_component(vect_t v){
double mag, angle, x_comp;
mag = v.r;
angle = v.theta;
x_comp = mag * cos(angle);
return (x_comp);
}
double y_component(vect_t v){
double mag, angle, y_comp;
mag = v.r;
angle = v.theta;
y_comp = mag * sin(angle);
return (y_comp);
}
vect_t add_vect(vect_t v, vect_t w);
vect_t final_vect;
double v_x_comp, w_x_comp, v_y_comp, w_x_comp, x_comp_tot, y_comp_tot, pathag, mag, theta;
v_x_comp = x_component(vect_t v);
w_x_comp = x_component(vect_t w);
x_comp_tot = v_x_comp + w_x_comp;
v_y_comp = y_component(vect_t v);
w_y_comp = y_component(vect_t w);
y_comp_tot = v_y_comp + w_y_comp;
pathag = (y_comp_tot)*(y_comp_tot) + (x_comp_tot)*(x_comp_tot);
mag = sqrt(pathag);[/TEX]
theta = atan2(y_comp_tot, x_comp_tot);
final_vect.r = mag;
final_vect.theta = theta;
return (final_vect);
```