How to calculate PI value with atan() function in C

2 Answers

0 votes
#include <stdio.h>     
#include <math.h>

int main(int argc, char **argv)
{   
	double pi = atan(1) * 4;
	
	printf("pi = %f\n", pi);
	
    return 0;
}
 
/*
run:
   
pi = 3.141593

*/

 



answered Apr 1, 2016 by avibootz
0 votes
#include <stdio.h>     
#include <math.h>

int main(int argc, char **argv)
{   
	double pi = 2 * atan(INFINITY);
     
    printf("pi = %f\n", pi);
	
    return 0;
}
 
/*
run:
   
pi = 3.141593

*/

 



answered Apr 2, 2016 by avibootz

Related questions

2 answers 603 views
2 answers 324 views
2 answers 403 views
2 answers 394 views
2 answers 440 views
2 answers 409 views
2 answers 483 views
...