How to use math constants M_PI and M_E in C

1 Answer

0 votes
// M_PI and M_E are not part of the C standard, but most compilers provide them.

#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>

int main() {
    printf("pi = %f\n", M_PI);
    printf("e  = %f\n", M_E);

    return 0;
}



/*
run:

pi = 3.141593
e  = 2.718282

*/


 



answered 2 days ago by avibootz
...