set initial value to avoid error

This commit is contained in:
Krishna Vedala 2020-07-10 23:59:51 -04:00
parent d186f59144
commit d1dfde4f89
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -21,7 +21,7 @@
*/
void to_polar(double x, double y, double *r, double *theta)
{
double thetaFinal;
double thetaFinal = 0.f;
*r = sqrt(x * x + y * y);
@ -46,9 +46,13 @@ void to_polar(double x, double y, double *r, double *theta)
{ // Q4
thetaFinal = 2 * M_PI - *theta;
}
else
{
fprintf(stderr, "Should not reach here!\n");
}
}
}
if (x == 0)
else
{ // exceptions when no actual angle is present
if (y > 0)
{