To use the constant M_PI in c++ we must include the lines:
#define _USE_MATH_DEFINES // for C++
#include <cmath>
at the top of the file. See here:
https://msdn.microsoft.com/en-us/library/4hwaceh6.aspx[
^]
So now we can use in this way:
#define _USE_MATH_DEFINES
#include <cmath>
#include<conio.h>
#include <iostream>
using namespace std;
int main()
{
double myPi = M_PI;
cout << M_PI << endl;
cout << myPi << endl;
_getch();
}