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 604 views
2 answers 325 views
2 answers 403 views
2 answers 394 views
2 answers 442 views
2 answers 410 views
2 answers 483 views
...