How to get the constant PI value from math.h in C

2 Answers

0 votes
#include <stdio.h>
#include <math.h>
 
int main(void)
{
	printf("%.2f", M_PI);
     
    return 0;
}

 
/* 
run:

3.14

*/

 



answered Feb 19, 2016 by avibootz
0 votes
#include <stdio.h> 

#define _USE_MATH_DEFINES 
#include <math.h>  

int main()
{
    printf("%f\n", M_PI);

    return 0;
}

/*
run:

3.141593

*/

 



answered Mar 6, 2018 by avibootz

Related questions

1 answer 117 views
117 views asked Mar 15, 2022 by avibootz
1 answer 103 views
2 answers 224 views
1 answer 192 views
2 answers 329 views
329 views asked Jun 5, 2016 by avibootz
1 answer 206 views
1 answer 224 views
224 views asked May 8, 2021 by avibootz
...