I am getting an “expected expression” error on this line:
} else if (y > 0) {
in the following snippet:
void cartesianToPolar(float x, float y, double *rPtr, double *thetaPtr){
// store the radius in the supplied address
*rPtr = sqrt(x * x + y * y);
// calculate theta
float theta;
if (x == 0.0){
if (y == 0.0); {
theta = 0.0; // technically considered undefined
} else if (y > 0) {
theta = M_PI_2;
} else {
theta = - M_PI_2;
}
} else {
theta = atan(y/x);
}
// store theta in the supplied address
*thetaPtr = theta;
}
I manually typed the example straight from the book. Any ideas on what might be wrong here?
Thanks!