hey,
as you might know calculator can be in radian or degree mode. This is needed when trying to use tan and sin.

I have noticed that c++ calculates tan in radian mode. I know that you can convert it by multiplying the answer by PI and deviding by 180

Is there any way to tell c++ to switch to degree mode so that I don't have to keep doing the long way with radian? thanks

2. and if there isn't, how can I use PI in c++?
(what's the word so that it recognizes it)

3. For PI in C++, I usually declare a constant to hold it, such as:

#define pi 3.14159265

It works well enough for me.

4. I would also just perform the radian to degree conversion yourself.. just keep in mind that there are precision limitations.

Here is a recent post that addresses pi precision.

5. Originally Posted by Mr.Pink
Is there any way to tell c++ to switch to degree mode so that I don't have to keep doing the long way with radian? thanks
No, but you could define your own function:
Code:
```double tand(double degrees)
{
static const double twoPiBy360 = (2 * 3.141592f) / 360.0f;
return tan( twoPiBy360 * degrees );
}```

6. In the cmath header there is a constant called M_PI that is the value of pi.

7. For PI in C++, I usually declare a constant to hold it, such as:

#define pi 3.14159265

It works well enough for me.
Much better to use a const in this case - what if you use the pi combination in a string?

8. String literals aren't parsed for macro replacements.

Code:
```#include <iostream>
using namespace std;

#define Hello 5

int main()
{
cout<<"Hello World"<<endl;
}```
Output
Hello World
Still its better to just use the predefined M_PI

9. Why, it's simple mathematics sir. First, you should have a const double for pi; something to the tune of:

Code:
```const double pi = atan(1)*4; //Or.....if you wanted to just go ahead and write it out:
const double pi = 3.14159265358979323; //A lot of that'll be truncated. ;)```
Radians to degrees is simply 180/pi, sir...which is something to the tune of 57.295, I believe. You can just multiply your radian value by a variable equal to that. You'd probably name the variable something spiffy like "RTD"(Radians To Degrees

And same goes for "DTR", some const variable to the tune of .01745 (which is the opposite: pi/180).

Not sure if I was any help whatsoever, but hey.

I remembered all those digits off the top of my head. That's downright special.