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 126 views
126 views asked Mar 15, 2022 by avibootz
1 answer 113 views
2 answers 233 views
1 answer 200 views
2 answers 338 views
338 views asked Jun 5, 2016 by avibootz
1 answer 216 views
1 answer 232 views
232 views asked May 8, 2021 by avibootz
...