I'm creating a program (console), that converts rectangular coordinates to polar coordinates (to help me on my math work). Now, the problem is that the answers for my problems, and the answers my program returns, are two different things. My answers are correct (according to my book, and a TI-83+ calculator).

Here's all my code I use to do the solving:

I don't understand why the answers are different. Is it because MSVC++'s tan returns different values, or maybe sin and cosin do also?Code:`double FindX(double r, double theta){`

cout << "x = r * cos(theta)\n";

cout << "x = " << r << " * cos(" << theta << ")\n";

x = cos(theta);

x *= r;

cout << "x = " << x << "\n\n";

return x;

}

double FindY(double r, double theta){

cout << "y = r * sin(theta)\n";

cout << "y = " << r << " * sin(" << theta << ")\n";

y = sin(theta);

y *= r;

cout << "y = " << y << "\n\n";

return y;

}

double FindR(double x, double y){

double x2, y2;

x2 = x * x;

y2 = y * y;

r = sqrt(x2);

r += sqrt(y2);

return r;

}

double FindTheta(double y, double x){

if((x > 0) || (x < 0)){

theta = atan((y / x));

}

else if((x == 0)){

DisplayError("Division By Zero!");

}

return theta;

}

double RT(double x, double y){

cout << "NOTICE: sqrt(...) means square root\n";

cout << " \"^-1\" means inverse\n\n";

cout << "r = sqrt(x^2 + y^2)\n";

cout << "r = sqrt(" << (x * x) << " + " << (y * y) << ")\n";

r = FindR(x, y);

cout << "r = " << r << "\n\n";

cout << "theta = tan^-1(y/x)\n";

cout << "theta = tan^-1(" << y << "/" << x << ")\n";

theta = FindTheta(y, x);

cout << "theta = " << theta << "\n\n";

cout << "( " << r << " , " << theta << " )\n\n";

return r;

return theta;

}